Unity and VR

This blog post documents some simple steps to get an initial Virtual Reality (VR) application built in Unity 5 to display and be controlled via the Oculus Rift DK2 Head Mounted Display (HMD) using Windows 10, Unity 5.2 and Oculus Runtime 0.7.

Initial Unity Project and Scene


  1. Create a new empty project. Note it already includes a “Main Camera” and a “Directional Light” to light the scene.
  2. Insert a simple solid ground plane to prevent your character dropping down. Use GameObject -> 3D Object -> Plane, for example, and make the object be located just below Y (something like -0.1) and have a decent extent in the X and Z directions. This will be able to be removed later when you have real content and terrain in your scene.
  3. Import the Environment Water via Assets -> Import Package -> Environment. Deselect the preticked assets using “None” and only select the “Water” assets and then “Import”.
  4. Under Assets -> Standard Assets -> Environment -> Water -> Water -> Prefabs, drop the WaterProDaytime prefab into the Unity hierarchy panel to include it in the scene. Set its Y position at 0 and scale it up in the X and Z directions.
  5. Under Assets -> Standard Assets -> Environment -> Water -> Water -> Prefabs, drop the WaterProNighttime prefab into the Unity hierarchy panel to include it in the scene. Also set its Y position at 0 and scale it up in the X and Z directions. Rotate this 180 degrees in the X direction. This has the effect of giving a water surface seen from underneath.
  6. Import the Characters Package via Assets -> Import Package -> Characters and select “All” and then “Import”.
  7. Then you will have available a Unity character “Ethan” in the standard Assets at Assets -> Standard Assets -> Characters -> ThirdPersonCharacter -> Prefabs folder which can be included in a Unity scene.
  8. The “Main Camera” already in the scene can now be dragged inside the “ThirdPersonController” hierarchy and it is then attached to the motion of the character.
  9. Now save the scene and save the project and you are ready to create the Unity builds for a range of platforms.
  10. For the Oculus Rift and VR, use File -> Build Settings… choose the PC/Mac/Linux Standalone and use “Player Settings” button to set the “Virtual Reality Supported” tickbox on. “Stereoscopic Rendering” should NOT be ticked. Then build the executable.
  11. You can also preview the scene in your VR HMD, if it is turned on, using the game mode preview within the Unity editor.


Unity Ethan and Other Avatar Models and Cameras

See notes in the Assets -> Standard Assets -> Characters -> ThirdPersonCharacter folder on how to replace the Unity Standard Assets Ethan character’s 3D model with other FBX avatar rigged meshes that are in a suitable format. The following blog posts also covers this process.

The attached avatar camera can also be made more sophisticated than the default Unity project “Main Camera”. An example of this is the flexible “UnityChan” character camera scripts included in Fumikazu Iseki’s OpenSim OAR Converter to Unity converter, in the “Unity3D” folder. For more details see…

OpenVCE OAR Converted to Unity and in VR

Using Fumikazu Iseki’s OpenSim OAR to Collada DAE and Unity Assets “OAR Converter” – see this blog post – the OpenVCE region in OpenSim was imported to Unity along with the Ethan character and Water layers as described above. When using the Unity editor game preview with the Oculus Rift DK2 turned on, the VR HMD display and head movement for camera direction all work fine.

2015-09-05-OpenSim-OAR-in-Unity-VR-2 2015-09-05-OpenSim-OAR-in-Unity-VR-3

Connecting the Unity Main Camera to the Oculus VR

“Oculus Utilities for Unity 5” (version 0.1.0 beta as at 10-Sep-2015) are available to add to your project…

If you are using the OAR Converter test avatar, UnityChan, in order to connect the VR HMD to the UnityChan camera, the advice from Fumikazu Iseki is…

Prior to build for VR applications, add OVR/Scripts/OVRCameraRig.cs
and OVR/Scripts/OVRManager.cs scripts to the UnityChan_Camera via
the “Add Components” button and using the “Script” type.


With the OpenSim OpenVCE OAR content converted and imported to Unity this is how the scene looks and works on the Oculus VR HMD both in editor preview mode and after a PC targeted build with “Virtual Reality Supported” ticked in the Build Settings -> Player Settings …


Experiments with Unity UI Elements

2015-09-10-Unity-UI-ElementsThe inbuilt UI elements were used to add drop down selections, buttons and floating text to which scripted event triggers can be added.

This entry was posted in Oculus, VR and tagged , , , , , , . Bookmark the permalink.