Esempio n. 1
0
    public static void VibrateTouch(Collider other)
    {
        leftControllerHaptics  = GameObject.Find("LeftHandAnchor").GetComponent <OculusHapticsController>();
        rightControllerHaptics = GameObject.Find("RightHandAnchor").GetComponent <OculusHapticsController>();

        // declare an empty pointer to locate which object did the button pushing
        GameObject pusher;

        switch (other.name)
        {
        case "HandCollider":
            pusher = other.transform.parent.gameObject;
            break;

        case "LeftHandAnchor":
            pusher = other.gameObject;
            break;

        case "RightHandAnchor":
            pusher = other.gameObject;
            break;


        default:
            pusher = other.GetComponent <CollisionHaptics>().pusher;
            break;
        }

        // VIBRATE the corresponding controller
        if (pusher == leftControllerHaptics.gameObject)
        {
            leftControllerHaptics.Vibrate(VibrationForce.Hard);
        }
        if (pusher == rightControllerHaptics.gameObject)
        {
            rightControllerHaptics.Vibrate(VibrationForce.Hard);
        }
    }