If you want to make your game work in VR, you need to activate the VR Split Mode. If you are a beginner and want to learn how to build virtual reality games, check out our Unity3D course!
Once you’ve integrated a VR software development kit (SDK), press Play to simulate the game. Notice that you will still not see the screen split to show the views of two cameras.
With Google VR SDK, we need to make a small adjustment to the game to view the scene in split mode. Stop playing the scene. In Assets, open the GoogleVR folder. Then open the Prefabs folder. We will use the GvrViewerMain.prefab file. This file has been saved for later reuse, so we do not have to build an entire game object that will change the scene.
Drag and drop GvrViewerMain.prefab to the Hierarchy. In the Inspector, you will see that the GvrViewerMain game object contains a Gvr Viewer (Script) component. This script does the VR logic.
Press Play. The Game window will show the scene from two cameras.
In the Hierarchy, click on “Main Camera”. You will see that this object contains Main Camera Left and Main Camera Right.
Click on “Main Camera Left”. In the Inspector, you can see that this camera’s X position is -0.032. Main Camera Right’s X position is 0.032. The distance between the cameras represents 6.5 centimeters, which refers to the distance between the human eyes.
A VR game contains two cameras to represent two human eyes. The left camera shows the scene from the player’s left eye. The right camera shows the scene from their right eye. With the help of a VR device, dividing the view into two cameras makes feel as though they are in a virtual world.
Create a cube in the Hierarchy. Move the cube closer to the camera. If you cross your eyes, you may be able to see the illusion that occurs because of the split view: the cube appears to be popping from the screen.
Press and hold the Alt/Option key. As you move the cursor, you will be able to look around the scene. If you hold Control, when you move the cursor, the scene will tilt. This could be used to change the weapon a player is holding when the player tilts their head.
Want to learn more? Check out our Unity3D course, where you build 30 virtual reality games!