cancel
Showing results for 
Search instead for 
Did you mean: 

Rotate around scene with Touch Controllers

DannyDan2468
Protege
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 1

DannyDan2468
Protege
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