Thursday, March 20, 2014

Getting started with Unity Pro

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:
  1. Create a scene.
  2. Import the Oculus integration package into the project’s assets.
  3. Add the Oculus Character Controller prefab (OVRPlayerController) to the scene or add the Oculus Camera prefab (OVRCameraController) to the character controller in your scene.
To get started with these steps, I first downloaded the OVR Unity 4Pro Integration package from It isn’t the smallest of downloads, so, while that was in progress, I fired up Unity and got started on the first step of Rift integration and created a 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....  

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.