Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
DannyDan2468's avatar
6 years ago

Rotate around scene with Touch Controllers

Is there a solution available for rotating a Scene when using the Local Avatar Prefab in first person view? I want to rotate around the playfield when using both Grip Buttons and the "gesture" known from so many other games.

Danny

1 Reply

Replies have been turned off for this discussion
  • I managed to get a little starting point by myself, but this is not turning around the scene object. But the gesture you need to do with the controllers is close to the one known from other games.

    public class RotateScene : MonoBehaviour
    {
        public GameObject scene;
        public GameObject player;
        float speed = 2;

        void Update()
        {
            if (OVRInput.Get(OVRInput.Button.PrimaryHandTrigger) && OVRInput.Get(OVRInput.Button.SecondaryHandTrigger))
            {
                Vector3 rTouchVelo = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch);
                Vector3 lTouchVelo = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch);

               if (rTouchVelo.z > 0.0f && lTouchVelo.z < 0.0f)
                {
                    player.transform.Rotate(new Vector3(0, -1 * (rTouchVelo.z * (speed)), 0));
                }
                else if(rTouchVelo.z < 0.0f && lTouchVelo.z > 0.0f)
                {
                    player.transform.Rotate(new Vector3(0, 1 * (lTouchVelo.z * (speed)), 0));
                }          
            }
        }
    }

    Maybe someone can point me to the right direction?

    Danny