Beispiel #1
0
    private void Release()
    {
        grabber.FixedJoint.connectedBody = null;
        grabber.StrongGrip.connectedBody = null;
        grabber.WeakGrip.connectedBody   = null;
        ConnectedObject.GetComponent <Rigidbody>().velocity        = position.GetVelocity(Hand) + transform.parent.GetComponent <Rigidbody>().velocity;
        ConnectedObject.GetComponent <Rigidbody>().angularVelocity = position.GetAngularVelocity(Hand) + transform.parent.GetComponent <Rigidbody>().angularVelocity;
        ConnectedObject.GetComponent <Rigidbody>().useGravity      = true;
        if (!ConnectedObject.GetComponent <Interactable>().SecondGripped)
        {
            ConnectedObject.GetComponent <Interactable>().gripped = false;

            ConnectedObject.GetComponent <Interactable>().GrippedBy = null;
        }
        else
        {
            ConnectedObject.GetComponent <Interactable>().SecondGripped = false;
        }

        ConnectedObject = null;
        if (OffsetObject.GetComponent <SteamVR_Skeleton_Poser>() && HandSkeleton)
        {
            HandSkeleton.transform.SetParent(transform, false);
            HandSkeleton.BlendToSkeleton();
        }
        OffsetObject.GetComponent <GrabPoint>().Gripped = false;
        OffsetObject = null;
    }
Beispiel #2
0
    private void Release()
    {
        grabber.FixedJoint.connectedBody = null;//disconnect everything
        //grabber.StrongGrip.connectedBody = null;
        //grabber.WeakGrip.connectedBody = null;
        ConnectedObject.GetComponent <Rigidbody>().velocity        = position.GetVelocity(Hand);
        ConnectedObject.GetComponent <Rigidbody>().angularVelocity = position.GetAngularVelocity(Hand);//set the rotational velocitiy too
        ConnectedObject.GetComponent <Rigidbody>().useGravity      = true;
        ConnectedObject.GetComponent <Rigidbody>().mass            = 50;
        ConnectedObject.GetComponent <Block>().Dropped();
        if (!SecondGrip)//if we were the first to grab the object
        {
            ConnectedObject.GetComponent <Interactable>().gripped = false;
        }
        else//if we were  the second hand
        {
            ConnectedObject.GetComponent <Interactable>().SecondGripped = false;
            SecondGrip = false;
        }

        ConnectedObject = null;
        if (OffsetObject.GetComponent <SteamVR_Skeleton_Poser>() && HandSkeleton)//disconnect the hand if needed.
        {
            HandSkeleton.transform.SetParent(transform, false);
            HandSkeleton.BlendToSkeleton();
        }

        OffsetObject = null;
    }
    private void OnDrawGizmos()
    {
        SteamVR_Action_Pose pose = SteamVR_Actions.default_Pose;
        Vector3             v    = pose.GetVelocity(SteamVR_Input_Sources.RightHand);
        Vector3             a    = pose.GetAngularVelocity(SteamVR_Input_Sources.RightHand);

        Debug.Log("V " + v.ToString("F4"));
        Debug.Log("A " + a.ToString("F4"));
        if (v.magnitude >= vThresh)
        {
            Gizmos.color = Color.cyan;
            Gizmos.DrawCube(GameObject.Find("Camera").transform.position + (GameObject.Find("Camera").transform.rotation *Vector3.forward).normalized * 2, new Vector3(0.1f, 0.1f, 0.1f));
        }
    }
        void DoGetAngularVelocity()
        {
            switch (velocityType)
            {
            case setAngularVelocityType.getAngularVelocity:
                velocity = poseAction.GetAngularVelocity(device);
                break;

            case setAngularVelocityType.getAngularLastStateVelocity:
                velocity = poseAction.GetLastAngularVelocity(device);
                break;
            }


            vector.Value = velocity;
            x.Value      = velocity.x;
            y.Value      = velocity.y;
            z.Value      = velocity.z;
        }