예제 #1
0
    protected void JointedRelease(VRControllerInput controller)
    {
        //Make sure joint isnt null
        if (fixedJoint != null)
        {
            //If object is still jointed to hand (could have been taken by other hand)
            if (fixedJoint.connectedBody == controller.GetComponent <Rigidbody>())
            {
                //Remove joint
                Destroy(fixedJoint);
                fixedJoint = null;
            }

            ThrowObject(controller);
        }
    }
예제 #2
0
    protected void JointedPickup(VRControllerInput controller)
    {
        //Check if it already has a joint (held by other hand)
        if (fixedJoint == null)
        {
            //Add joint to object
            fixedJoint = gameObject.AddComponent <FixedJoint>();

            //You don't have to set a break force, but if you don't,
            //when you drag your object behind immovable things, they'll just weirdly be
            //stuck behind them until you let go.
            //By setting a break force, you "drop" the item under too much strain.
            if (useBreakForce)
            {
                fixedJoint.breakForce = 500;
            }
        }

        //Attach to controller
        fixedJoint.connectedBody = controller.GetComponent <Rigidbody>();
    }