Example #1
0
    void OnTriggerEnter(Collider other)
    {
        GrabHandCollider grabber = other.gameObject.GetComponent <GrabHandCollider>();

        if (grabber != null)
        {
            switch (grabber.hand)
            {
            case GrabHandCollider.Hand.LEFT:
                leftHandInCollider = true;
                break;

            case GrabHandCollider.Hand.RIGHT:
                rightHandInCollider = true;
                break;
            }
        }
    }
Example #2
0
    void OnTriggerExit(Collider other)
    {
        GrabHandCollider grabber = other.gameObject.GetComponent <GrabHandCollider>();

        if (grabber != null)
        {
            float leftGrip  = TouchInput.LeftGripSqueezeFraction;
            float rightGrip = TouchInput.RightGripSqueezeFraction;

            // only let go if we've exited the trigger _and_ we've let go of the grip.
            if (grabber.hand == GrabHandCollider.Hand.LEFT && leftGrip < 0.5f)
            {
                leftHandInCollider = false;
            }
            if (grabber.hand == GrabHandCollider.Hand.RIGHT && rightGrip < 0.5f)
            {
                rightHandInCollider = false;
            }
        }
    }