DEV Community

Ng Chen Hon
Ng Chen Hon

Posted on

5

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay