Welcome! What an exciting time for Virtual Reality. Today I’m going to show you how to build your own VR application for the Oculus Rift from scratch!

Whether you are brand new at developing an app – or you are a seasoned veteran – this post is for you. That’s because pretty consistantly every new Oculus runtime and SDK have always had unique steps and weird quirks to get you to the point where you can make apps. And often involve a lot of steps that send you all over the internet to find out how to do it. With this post I am going to walk you through it from the start and you will have a built app at the end of it. Excluding times for downloading, installing and rebooting, you will have a VR app working within minutes.. :-)

Some good news for DK2 owners: These steps will work with both CV1, DK2, or Gear VR (for those still waiting)

I’m going to show you how to develop an app using Unity3d v5 and Oculus VR.

Your VR Setup:

oculus_rift_setup

For this tutorial you will need:

  • A VR Headset: Oculus CV1 or DK2.Buy one from Oculus Store, Oculus Ready PCs or ebay.Note: Even though I say this tutorial works with Gear VR – that is not the best system to develop and test with because you still can’t plug a Gear VR directly into the Unity3d to use for interactive testing. So I definitely recommend you have a DK2 or CV1 for this. You can still build your VR app to work on GearVR as well.

Step 1. Remove any previous Oculus Runtime:

(You can skip this step if you have never had Oculus installed on your PC, or you already have installed the current Oculus Runtime 1.3. If you have the ‘Oculus Home” experience, then you have 1.3).

For correct operation you want to make sure any previous runtime is completely removed, in particular Oculus Runtime 0.8 which was widely used in the lead up to the Rift release.

  • Uninstall Oculus Runtime:Go to Start->Settings->System->Apps & Features : Click on “Oculus Runtime” and press Uninstall.Note: Uninstalling the Oculus Runtime will also uninstall the sensoruninstall oculus runtimeFollow the prompts to uninstall.
  •  IMPORTANT: Make sure you restart your PC before continuing.

Step 2. Setup your Rift

(Like Step 1: You can skip this step if you have never had Oculus installed on your PC, or you already have installed the current Oculus Runtime 1.3. If you have the ‘Oculus Home” experience, then you have 1.3).

Before you can build your own VR applications, you should make sure your Rift is correctly installed and you can play existing applications or games.

Oculus have a well documented installation process here.

However, they key steps are:

Step 3. Install and setup Unity 3d

At this time (22 April 2016), the officially recommended version of Unity is a patch build v5.3.4p1.

You can use Unity as the free or professional (licensed) version to create VR. The professsional version allows you to customize the splash screen to remove the Unity logo, and provides more powerful features. For this tutorial I recommend the professional trial version.

By the time you read this that may have changed. To keep up to date with the correct version see the Oculus Forum post Recommended Unity Versions For Development.

  • Download and Install Unity v5.3.4p1.

    unity_534p1IMPORTANT: Use the “Unity Editor Download Assistant”  so that you can choose to install Windows and Android build support components:unity_download_assisstant
  • Patch Unity3d with the latest Oculus pluginDownload Oculus Plugin 1.3.2 for Unity 5 and follow the instructions to patch:
  1. Close the Unity Editor if it is currently running.
  2. Navigate to C:\Program Files\Unity\Editor\Data\VR\oculus
  3. Delete all contents of the directory.
  4. Extract the OVRPlugin zip, open the folder 5.3\oculus, and copy all of its contents into C:\Program Files\Unity\Editor\Data\VR\oculus.

 

  • (Optional) Download the Oculus Utilities 1.3.2 for Unity 5You can develop Oculus VR apps without the utilities by using only Unity 3d native VR. However, there are a lot of useful features in the Oculus Utilities – such as the OVRPlayerController to quicjly enable your player to walk around using the XBox Controller or keyboard.I recommend downloading this.Once downloaded, unzip ovr_unity_utilities_1.3.2 and copy the OculusUtilities.unitypackage into the Unity standard assets folder: “C:\Program Files\Unity\Editor\Standard Assets”.
  • IMPORTANT: Allow Unity to use the VR headset by enabling “Unknown Sources” in the Oculus Home settings panel. (If you don’t, you will see an error in VR that Unity does not have permission).
    Oculus Home settings

Step 4. Create a Unity Project

  1. Launch Oculus Home (if it isn’t already running)
  2. Launch Unity3D
    On the launch wizard press [New+] and create a new 3D project (make sure 3D is hilighted in pink):(Optional) if you want to use the Oculus Utilities for Unity, then click [Asset packages…] and select “OculusUtilities”:

    Press [Create Project] and you will be in the Unity Editor:


    Unity3d
  3. Create a new project scene: File -> “New Scene”, then File -> “Save Scene As …” and name it “main”
  4. Add the scene to your build settings: File -> “Build Settings” and press [Add Open Scenes] to add “main” to your project:
    build_settings
  5. Set your project to support VR mode by opening [Player Settings…] button, and checkmark “Virtual Reality Supported”:
    player_vr_settings
  6. Create some content by adding a plain old cube into the scene. Right click in the Hierarchy window panel and select “3D Object->Cube”, and you will see a cube appear in the scene and game windows:
    unity_cube
    Note: Press File->Save (CTRL-S) to save this change (in case Unity crashes).
  7. That’s it! To test this in VR, press the PLAY button (above the game window). The game window will show you what the player is seeing. Try and move your Rift around and the tracking will alter the game view:game_view
  8. Now look through the CV1/DK2 headset and you will see a Health & Safety Warning. Follow the instructions to dismiss it (press XBox A-Button, Press Select on the Oculus Remote, or Hover the cursor over the text to dismiss it):Health_and_Safety_WarningNow, you will find you are seeing your cube !!Note: At this stage there is no way to disable the Health & Safety Warning for developers (which was previously possible). Hopefully Oculus will add that option in the future.
  9. Press the now Blue PLAY Button again to STOP and return to edit mode (Any edits you make while playing are lost when you stop). Looking through the VR headset now you will see black. Experiment by adding other objects to the scene and pressing PLAY again.You will see your new changes in VR.

Well done! Although this is very basic – it is a real VR app !

Step 5. Building your app to share

The last step is to export your app as a build that can be shared around without the Unity 3d editor.

  1. Open Build Settings again (File->”Build Settings”) and press [Build]. Save your build as “HelloWorldVR.exe”.buildingOnce built it will open up the location in file explorer.
  2. Click on “HelloWorldVR.exe” to run the app (checkmark “Windowed” to make it easy to quit):
    run
    That’s it !! You’ll see the Unity Splash screen, and finally be in your game (Note: In the VR Headset you’ll have to dismiss the Health & Safety Warning):launching
    game

And that’s it. To share this, zip up the HelloWorldVR.exe and HelloWorldVR_Data folder, and you can send it to others to play!

Next Steps

You now have everything you need to get started on your VR app journey.

If you are interested in 3D, download an FBX formatted 3D model from a site like http://turbosquid.com. A FBX file typically includes model geometry, textures and materials, and can be imported easily by Unity 3d.

Eg: Here’s a free vehicle on Turbo Squid:

http://www.turbosquid.com/3d-models/mitsubishi-lancer-evolution-ix-3d-model/541310

turbosquid_car

Download the FBX zip file, and extract it. Then drag the MitsubishiLanserEvo-fbx into Unity (into the project Assets window panel).

Unity will import the model and once done you will have a MitsubishiLanserEvo-fbx/MitsubishiLanserEvo-fbx prefab (which has a blue cube icon next to it):

fbx

Simply drag the prefab into the Hierarchy window panel to add it to the scene at position (0,0,0):

car_in_unity

Now press PLAY and you can see the vehicle:

carGood luck!

Send me any comments and feedback.