<< Back to tutorials

First VR in Unity3d with the Oculus Rift!
 Live on: May 5 2016 at EN 3026

Download Unity 5

Go to the Unity website and download the most recent Unity 5: download here.

The free version will include everything you need in order to make a VR project in Unity 5. If your computer can do the 64 bit version, I recommend it. The exception is if what platform you are developing for is limited to 32 bit. As of this writing, the most recent Unity version is Unity 5.3.4. However, this tutorial should be accurate for a while. If you get a slightly newer version, don't worry about it.

Install Unity

The installation of Unity is straight-forward: next, next ... next. When you are installing it and make it to the section "Choose Components" make sure to check the box "Android Build Support" if you think you will later do a program for the Google Cardboard. But it is not necessary for this tutorial actually (I just want to save you some time now).

Set Up the Oculus Rift

Connect your Oculus Rift (CV1, DK1, DK2) to your computer as usual. There is no need of installing any special software for interfacing Oculus with Unity, besides the "Oculus Runtime" that you must already have installed when you first tried your Oculus.

Create your Unity Project

Now we will create a project for our game. Open Unity, you will see an initial screen that lets you create a project. You can name it whatever you like. Make sure it is configured as a "3D" game and saved in a place that you know where to find it.

When Unity opens up, it should look something like this (click the image to see a larger version). You can orbit the scene by using ALT and dragging the left button of your mouse. If you ever get lost, select an object from the hierarchy and press "F", this will focus that object in your Scene panel again.

It starts you out with a light source and a camera. The first object we will create is a plane that we can walk on.

  1. Go to the main toolbar and select GameObject -> 3D Object -> Plane. This creates a plain white plane in your scene. It should now look like this:

  2. If you click the run button at the middle top of Unity's window you can see your project runs but doesn't do anything yet.

  3. To enable VR Support and watch your scene in the Oculus select from the main toolbar: Edit -> Project Settings -> Player. This opens the PlayerSettings panel. In this panel go to Other Settings and check the box next to "Virtual Reality Supported". It will look like this:

    Your project is now set up for VR. Go ahead and save your scene as "MyFirstScene".

  4. Run again your scene and put on your oculus. You can now rotate your head around and see your plane from different perspectives. But we still cannot walk around it.

  5. For walking around the plane (with the WASD keys or the arrow keys), we need to import the "Characters" package. Do this by going to "Assets -> Import Package -> Characters". It will take a while to refresh the package contents and then you can click "Import". You will see a new folder in your project called "Standard Assets".

    Now you need to insert into your scene the prefab that lets you walk around the scene. Go to the folder "Standard Assets -> Characters -> FirstPersonCharacter -> Prefabs". And find one called "FPSController":

    Drop the "FPSController" into your scene. It should now look like this:

  6. Notice now we have two cameras in our scene, in order to run our scene we need a single camera. Go on and delete the one called "Main Camera". So you should only have these components in your scene:

    At last you can run your scene and walk around with the arrow keys and jump with the spacebar. And of course, you can turn your head around with the Oculus!

  7. Now how about adding a cool texture to your plane? Right click this cat and download to your "Assets" folder. Unity will import it automatically.

    Cool cat credits: ToValhalla at DeviantArt

    Now drag and drop the cat from inside Unity, from your "Assets" panel to your ground plane, and you should get something like this:

    Quite easy adding a texture don't you think? It's the same for importing 3D models, just drag&drop. Why don't you try it out next?

  8. You can improve the scene with more objects from the Unity Asset Store, there are lots, and some of them are free:

    There are plenty of Unity tutorials on Youtube or on the Unity site. I recommend the Youtube tutorials over Unity's tutorials as the Youtube ones are usually much more up to date and cover a wider range of topics. You can now also now save and build your project to create an executable.

  9. Congratulate Yourself!

    You have now successfully completed this basic Unity VR Project tutorial.

    Created by:
    Russell N. Todd

    << Back to tutorials