DEV Community

Ng Chen Hon
Ng Chen Hon

Posted on

Using GvrEditorEmulator Prefab From GoogleVR Package and Not Sinking the Camera Downward Until the Parent Center On Unity Editor

If you are making a game targetting Cardboard or Daydream platform. You might need to dump the GvrEditorEmulator prefab came with GoogleVR package into the scene and pair a camera with it.


Let's say this is how you setup your scene :

  1. You have to child the camera within a GameObject parent.
  2. The parent have a shape.
  3. The camera should be at the "head" of the parent which deviates away from the center of the parent.
  4. You have GvrEditorEmulator paired with that camera and enabled.

The good thing is that you can pan around to view 360 degrees by tapping Alt + mouse moving around.

However, it appears that the camera is sinking downward.

The GvrEditorEmulator script will always try to default the local position (position relative to the parent) of the camera to Vector3.Zero which is (0, 0, 0).


To prevent that :

// line 90
m_camera.transform.localPosition = neck;

// line 103
m_camera.transform.localPosition = Vector3.Zero;
Enter fullscreen mode Exit fullscreen mode

Open up GvrEditorEmulator script with your favourite IDE and comment out the lines at 90 and 103.

That should prevent the camera from sinking downward from the intended y position.

Top comments (0)