loading

This tutorial goes through how to make a VR (virtual reality) app for your mobile device using the new Google VR plugin for Unity (Daydream VR). The app can be built to run on Android or IOS phones as long as they are compatible with Google Cardboard. I tried to make this as quick and simple as possible. The game consists of a maze that you can navigate through. Your first person character walks forward in whatever direction your head is facing, if you look at the ground you stop walking.

Subscribe to my YouTube channel for more videos https://www.youtube.com/channel/UClm2DY6pj3ygKoKhE...

I will also be doing a video on Daydream controller support as soon as I get my hands on one.

To follow along you will need:

Unity 3D: https://unity3d.com/

The Google VR plugin: https://developers.google.com/vr/unity/download

(click "download the repo directly)

Thanks for looking and let me know in the comments if you have any questions!

Step 1: Create a New Project:

Create a new Unity Project and drag the two images above into the assets folder.

Go to the GVR plugin folder and drag "GoogleVRForUnity.unitypackage" into the assets folder as well.

Go the the asset store tab and download and import the Cope! free skybox pack.

Delete the camera in the hierarchy.

Go to the GVR folder in Unity, and navigate to the legacy, prefabs folder. Drag in the main prefab into the scene.

Right click in the hierarchy and create a new 3D object plane.

Drag the maze image onto the new plane.

Step 2: Start Creating the Scene.

Click the main camera, as well as the left and right, and change their background from solid color to skybox.

Go to the scope skybox pack folder and drag in your desired skybox from the materials folder into the scene.

Right click in the hierarchy and create a new 3D cube.

Scale the cube to make the first wall for the maze. Drag on the grass picture to this first cube.

Keep duplicating that cube to build the walls to the maze.

Step 3: Complete the Scene

Once the maze portion is complete it should look like the image above.

Click the GVR main in the hierarchy and go to the inspector side.

Add a rigidbody component and click the checkbox to freeze the x and z rotation.

Now add a capsule collider component.

Make sure to scale the collider so its bottom is just above the plane, and also scale it to make sure the collider will fit inside the walls of the maze.

Step 4: Write Some Code.

In the same inspector view click to add a component to the GVR main.

Add a new c sharp script, and call it "controller.cs"

Double click that script to open up Mono Develop.

Copy and paste this code into the new script.

using UnityEngine;
using System.Collections;

public class controller : MonoBehaviour {

	private bool walking = false;
	private Vector3 spawnPoint;

	// Use this for initialization
	void Start () {
	
		spawnPoint = transform.position;
	}
	
	// Update is called once per frame
	void Update () {

		if (walking) {

			transform.position = transform.position + Camera.main.transform.forward * .5f * Time.deltaTime;
		}

	
		if (transform.position.y < -10f) {

			transform.position = spawnPoint;
		}

		Ray ray = Camera.main.ViewportPointToRay (new Vector3 (.5f, .5f, 0));
		RaycastHit hit;

		if (Physics.Raycast (ray, out hit)) {

			if (hit.collider.name.Contains ("plane")) {
				walking = false;
			} else {

				walking = true;
			}

		}


	}
}

Step 5: Now You Have a Game

Click File, Build Settings, and change the bundle identifier to com."something"."something"

Now switch your build platform to IOS or Android depending on what type of phone you want to run the game on and click build and run.

Thats it!

Any questions, don't hesitate to ask!

Let me know in the comments what other tutorials you would like to see!

<p>start the game on pc works just fine, but if i build on my android device oneplus one 6.0 the maze is gone, only the skybox, what should i do?</p>
What version of unity did you use? The google sdk doesn't work for me, it says the script has compiling errors. Thanks!
<p>can't download the zip file..?</p>
Nice, I recently had to make a game for a school comp and it included mazes made in unity. It's funny cause I used the same method you did and even used the same maze template
<p>lol nice, but yeah it makes it so much easier. </p>

About This Instructable

7,734views

178favorites

License:

Bio: My name is Matthew and I attend the University of Pittsburgh. Currently I am a senior, going for a bachelors in Information Science with a ... More »
More by matthewh8:Lets Make an Augmented Reality App in 6 MINUTES! TRUMP EDITION  How to Markerless Augmented Reality Tutorial: SLAM Make a Killer Augmented Reality App 
Add instructable to: