Unity Pro is a popular game engine so let’s take a look at getting started with Rift development using Unity Pro. The basic integration steps look pretty easy:
- Create a scene.
- Import the Oculus integration package into the project’s assets.
- Add the Oculus Character Controller prefab (OVRPlayerController) to the scene or add the Oculus Camera prefab (OVRCameraController) to the character controller in your scene.
For a minimal Rift scene, all you need is a plane to stand on, a light to see by and some objects to look at. Not being someone who is happy doing the bare minimum, I used the Terrain Assets standard Unity package to add a little bit of flair to my scene and created a sand beach with palm trees.
With my scene ready, the next step was to import the Oculus integration package into my project by using Assets->Import Package->Custom package and selecting the OculusUnityIntegration.unitypackage that I downloaded earlier from OculusVR. After importing the package and saving the scene, I had an OVR folder in my project’s assets and an Oculus menu item in my main menu listing two prefabs: OVRPlayerController and OVRCameraController. The OVRCameraController prefab is a stereo camera that is used in place of a single Unity camera, and the OVRPlayerController prefab is an OVRCameraController prefab attached to a character controller.
I wanted to see my scene running on the Rift right away, so I went with the more complete option and dragged the OVRPlayerController prefab onto my scene. Then, all I needed to do was properly position the prefab so that it was above the plane. After re-setting the Prefab location to the origin point, I looked at the character controller on the prefab to see that it had a default Height of 2 and a Radius of 0.5. Not wanting my character buried in the sand, I set the Transform Y position to 1. When I switched the scene to the Game view, the scene now showed left and right views.
With the prefab in place, I selected “Maximize on play” and clicked play. And, I got an error: "There are two Audio Listeners in the scene. Please ensure there is always exactly one audio listener in the scene." Both the Oculus prefab and the default Main Camera that I still had in the scene have Audio Listeners attached. After deleting the default Main Camera, I was ready to give it another whirl. After pressing play, with the Rift attached, my scene was now displayed in the Rift’s oval views.
I put my Rift on and there I was standing on the sand beneath the palm trees. Now, I just need to add some surf and some sun....