How to move the camera in VR mode?
Hi... I'm beginner to unity.... I use GoogleVR to see the game in VR mode and i want to use navigation in the game mode.... i use this code to do this but the problem is when i turn my head it doesn't go through my head direction!!!
Public GameObject Camera1;
void Update () {
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Camera1.transform.Translate(h * 0.01f, 0f, v * 0.01f);
}
what should i do?!!!
Answer by BodhiPurplePill · Apr 20, 2017 at 12:02 AM
VR overrides the camera's position and rotation. Try giving the camera a parent, and move that parent object instead.
Answer by Hooman-BZ-1989 · Apr 20, 2017 at 02:43 PM
Thanks @BodhiPurplePill but it doesn't work .... I've even tried to Rotate the parent of my VR Camera but it didn't work!! Its the code of the parent:
public GameObject VRHead;
float YRotation = VRHead.transform.rotation.eulerAngles.y;
transform.rotation = Quaternion.Euler(0f, YRotation, 0f);
I assigned Head in GVRMain to VRHead in the script and when i play, the parent rotates with a really fast speed and doesn't stop!!!!!!