Oculus Rift is a very popular VR headset, so knowing how to enable and setup developer mode is invaluable. Once in developer mode, you’ll be able to start development in Unity with Oculus assets and more. This is an important part of VR development, so let’s get started.
To create apps for the Oculus, you need a laptop/desktop computer, copy of Unity 3D and Oculus Integration. Unity is a content creation tool for building VR applications — you can create, test, and publish your original ideas on Oculus Home! Oculus Integration is a unity plugin that allows you to build apps for the Oculus with the correct framework.
To start things off, Usman will be sharing our Oculus Rift set up video with Unity. Next, we’ll go over a three step recap of the video and some common issues.
|Download our 10-week VR Development with Unity Course Syllabus|
Step 1: Get Unity Ready to Go
Unity is free to install and use. So if you don’t already have it, at this point you’ll want to start by installing the latest version. Once you have Unity installed on your computer, create a new 3D project by clicking File > New Project. Name your project, select 3D from the Template dropdown menu and click Create Project.
Once you’re in the new project, click on File then Build Settings. From the Build Settings menu, click Player Settings > XR Settings and check Virtual Reality Supported. Make sure “Oculus” appears in the list. If it doesn’t, click the plus symbol below and select “Oculus” from the dropdown menu that appears.
That’s how easy it is to prep Unity for Oculus development. Now all we need to do is officially add Oculus Integration to our project.
Step 2: Connect the Oculus Integration Plugin to Unity
Click on the Asset Store tab (Window > Asset Store) and search for “Oculus Integration” at the top.
It will pop up as an option, and you can select, download and import it into your project directly from that window. Do it.
At the end of your import, you may see a prompt that says “API update required.” Get rid of the problem by clicking on “I Made a Backup, Go Ahead!”
That’s it for Oculus Integration! Now we’re going to import the Oculus Camera, which represents the VR headset and the player’s eyes in your project.
Step 3: The Camera (OVRCameraRig and Main Camera)
In your Assets tab, navigate to OVR > Prefabs (or Oculus > VR > Prefabs).
From the Prefabs folder, click and drag the OVRCameraRig into your scene.
Now your project is doing something funny. You’ve just set up an entire camera rig in your scene, but you already had the Main Camera doing similar things. So we need to delete the original Main Camera, to stop it from interfering with your newly imported OVRCameraRig.
Find your hierarchy tab, find the words “Main Camera,” select the Main Camera and delete it. Problem solved!
Now that we got the Main Camera out of the way, let’s set up our OVRCamera Rig.
Click on the OVRCameraRig in your Hierarchy tab. Then, take a look in the Inspector tab on the far right of your screen for Tracking Origin Type in the OVR Manager (Script) component. Click the Tracking Origin Type property so a drop down menu appears, and select Floor Level.
This will set the user’s position and orientation relative to the floor. The position is calculated based on the user’s height, which they indicate in their profile when they set up their Rift. This means the user’s position will change depending on each user’s unique information.
So even if you’re making your app for a wide range of users, it’ll adjust to accommodate everyone!
Step 4: Oculus Touch Controller Set Up
We’ve set up the cameras, which represent the player’s eyes. Essentially, the Oculus Rift headset is now a part of this project. Now, we need to set up the controllers, which represent the player’s hands.
To enable the player to use their Oculus Avatar hands, find your Assets tab and navigate to OVRAvatar > Content > Prefabs (or Oculus > Avatar > Content > Prefabs).
Next, click and drag the LocalAvatar prefab into your scene.
Done! Now that we have the controllers in the scene, your player will be able to interact with objects within the application you build. But we still need to make the controllers visible as avatar hands.
Start by clicking the LocalAvatar game object in your Hierarchy Tab.Then, take a look at your Inspector tab. Under the OVR Avatar (Script) component in the Inspector tab, find the “Start With Controllers” property and make sure it’s selected.
Save the scene. You now have a project that’s ready to develop for the Oculus Rift!
|Preview our 10-week VR Development with Unity Course Syllabus|
Step 5: Click Play!
Turn on your Oculus Rift controllers and click Play in Unity.
You should be able to see your scene as well as your two touch controllers. If your scene doesn’t look like much, that’s because it isn’t at this point. Now that you’re all set up, it’s time to get building and turn that space into something incredible!
You should also see your controllers moving around in the Scene tab.
Before you move ahead with your project, make sure you’re familiar with the capabilities of your hardware. Start by checking out all of the button inputs on your controllers. You’ll find it has a range of input options that include:
- Button One, Button Two, Button Three ,Button Four, Button Start, Button PrimaryThumbstick and Button SecondaryThumbstick
- PrimaryIndexTrigger, SecondaryIndexTrigger, PrimaryHandTrigger, SecondaryHandTrigger, PrimaryThumbstick and SecondaryThumbstick
As you continue to develop your scene, make sure you take advantage of the huge amount of resources at the Oculus Developer Center.
Remember, if you run into any trouble or need one-on-one guidance from Unity pros, you can always find it in our live 10-week course.
Common Error: I Can’t See My Controller!
If you can’t see your Touch Controllers in the scene, and Unity is giving you an error in the Project tab, try these fixes:
- Reinstall the latest version of Unity.
- Reinstall the latest version of the Oculus app. Sometimes, the Oculus app doesn’t update past a certain version and reinstalling can be a quick fix. Download Oculus here.
- If prompted, update your firmware (headset, controllers and sensors).
- Make sure your Oculus Touch controllers are paired with your headset. From the Oculus app, click Devices > Right Touch / Left Touch > Forget Device on your old controllers. Re-Pair your controllers under Device > Configure Rift > Pair Touch. If both controllers say On you should be good to go!
- Go to Build settings > Player Settings > XR Settings and check Virtual Reality Supported. Make sure “Oculus” appears in the list otherwise click the plus symbol below and select it from the dropdown menu that appears
- Go to the Unity Asset Store tab(Click Window > Asset Store) in Unity and search Oculus Integration in the search field at the top.
Download and import the Oculus Integration into your project.
- At the end of the import you may see a prompt that says API update required. Click on “I made a backup, go ahead!”
Navigate to OVR > Prefabs in your assets tab.
- Click and drag the OVRCameraRig prefab into your scene.
- Delete the Main Camera from the scene in the hierarchy tab as it will interfere with the OVRCameraRig. Select OVRCameraRig from your Hierarchy tab, then look in the inspector tab. Look for “Tracking Origin Type” in it’s “OVR Manager(Script)” component. Click that property so a drop menu appears, select “Floor Level”.
- To enable the Oculus Avatar with hands and to use the controllers navigate to OvrAvatar > Content > Prefabs in your assets tab.
- Click and drag the LocalAvatar prefab into your scene.
- Select LocalAvatar from your Hierarchy tab, then look in the inspector tab. Look for “Start With Control” in it’s “OVR Avatar(Script)” component, make sure the the box next to it is checked.
- Save the scene! You now have a project ready to develop for the Oculus Rift!