6 Steps to Set Up Your Oculus Rift with Unity in Less Than 10 Minutes [2021 Updated]
Last Updated: December 27 2021
Even though Oculus Rift got overshadowed by his younger and more nimble brother Oculus Quest 2, it is still a popular PC VR headset.
With the Oculus Link, millions of Quest 2 users can now connect their headset to their PCs and enjoy a huge library of PC VR games. With the recent upgrade of 'Air Link' feature even the USB cable isn't necessary.
This means if you own an Oculus Rift, you have a perfect opportunity to build and test high-demand VR applications for an ever-growing base of Oculus users.
So it's imperative to know how to set up your Oculus Rift for developer mode.
Once in developer mode, you'll be able to start development in Unity with Oculus assets and test your apps on the go. So here's a short tutorial!
A couple of technicalities, in case you just ordered the Rift S and you want to use it for your gaming laptop - Oculus decided to put an USB port on one side of the cable (all good so far) and a Display Port in the end of the cable which of course is outdated and non-compatible for most computer's I/Os.
To avoid the issue, order a Displayport to Type-C adapter ahead of time. We recommend getting a Type-C instead of HDMI port adapter since most of the users report issues with HDMI adapters.
The setup process for Rift and Rift S is identical. Rift S is just an upgraded version with sharper LCD display.
Before you get started, Oculus does recommend checking out minimum system specifications for using Oculus Rift. Make sure you have adequate specs!
Processor: Intel i3-6100/AMD Ryzen 3 1200, FX4350 or greater.
Graphics Card: NVIDIA GTX 1050 Ti/AMD Radeon RX 470 or greater.
Alternative Graphics Card: NVIDIA GTX 960 4 GB/AMD Radeon R9 290 or greater.
Operating System: Windows 10.
Memory: 8 GB RAM.
USB Ports: 1 x USB 3.0 port.
How to Prepare Your Oculus Rift For Development
At this point we are assuming that you've already used Oculus Rift before and are familiar with their core features such as the guardian system (where you trace the edge of your play area to stay within guardian boundaries while in VR), and have gone through the full setup already.
- Unity is an application that lets you build, test, and publish your original content on Oculus Home! In other words, it's a content creation engine for building VR applications.
- Oculus Integration Package 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.
Once you've downloaded Oculus Rift software make sure you have the latest Oculus updates installed. Depending on the time of the setup, the Oculus software package is the size of 5GB and more.
If you're having issues with the initial setup, we recommend that you contact customer support at Facebook technologies. Some problems are trivial, for example, having sufficient disk space on your computer and making sure that your computer satisfies the minimum requirements such as graphics card or RAM for the best VR experience.(Check out our guide on VR hardware or check your desktop capabilities with the new device with SteamVR performance checker).
Let’s take a deep dive into virtual reality development!
Step 1: Connect Your Oculus Rift with USB
Before we start, open the Oculus Companion App on your phone and go to Settings > More Settings > Developer Mode and toggle the Developer Mode on.
Now plug your Oculus Rift in your PC using a USB cable. Make sure you’re using a USB-C cable or Oculus Link cable. In the following prompt, Allow USB Debugging and check whether Always allow from this computer is on.
Now we’re able to launch and test VR applications using your virtual reality headset! Let’s proceed to setting up your Unity environment.
Do I Need a Facebook Account to Develop Apps With my new Oculus Rift?
According to the Facebook guidelines for Oculus users, everyone who uses previous generation Oculus devices for the first time will need to log in with a Facebook account. The guidelines were introduced in October 2020.
So you need a Facebook account if you want to access Oculus Store and purchase content. But it’s a bit more complex than that.
If you want to use Oculus Rift exclusively for development purposes without accessing content from the Oculus Store, you have a choice: either connect your development account to your personal Facebook or set up a Test User account to test your VR applications.
In 2023, Facebook will cease supporting legacy Oculus Accounts and might require Facebook accounts from new developers that are not using Oculus for Business Platform.
Step 2: Prepare Unity for VR Development
We're going to start by downloading the newest version of Unity engine. Install Unity on your computer by running the installer package and following simple instructions. Once you have Unity installed, create a new 3D project by clicking File > New Project. Name your project, select 3D from the Template dropdown menu and click Create.
Once you’ve created the new project, click on File then Build Settings. Let’s go through a couple of settings here:
- Set Platform to PC, Mac & Linux Standalone.
- Under Target Platform, select Windows (or other OS if it's different).
- You can toggle Development Build later to test and debug the app.
Note: Clear this selection when you’re to release the final build.
Finally, let’s enable VR support before we start building our first VR application:
- Go to Edit > Project Settings.
- Click XR Plugin Management, then go for Install XR Plugin Management.
- Open the Windows tab and select Oculus to install the Oculus XR plugin and enable the VR support in Unity.
Note: If you’re using older Unity versions (before 2019.3), follow these instructions instead to enable VR support in Unity:1) From the Build Settings menu, click Player Settings > XR Settings and check Virtual Reality Supported.
2) 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.
We’re done with preparations. Let’s dive into creating our testing VR environment in Unity!
Step 3: Connect the Oculus Integration Plugin to Unity
Follow the screen instructions: click on the Asset Store tab (Window > Asset Store) and search for “Oculus Integration” at the top.
First, you need to download the package. After that proceed by clicking Import in the Asset store. To finish the import, click the Import button as shown below:
After that the Oculus Integration package will be imported into our current project.
Now we can use Oculus package components and assets to quickly set up our Virtual Reality environment.
Let’s start with setting up Oculus Camera that represents the position of VR headset and your players’ eyes.
Step 4: Set Up The Camera (OVRCameraRig and Main Camera)
In your Assets tab, navigate to Oculus > VR > Prefabs.
From there, click and drag the OVRCameraRig prefab into your scene.
Your project is now acting funny as there are two different cameras in one scene. The default Main Camera and the OVRCameraRig that we’ve recently added. Delete your original Main Camera in order to avoid conflict with your newly imported OVRCameraRig.
Browse your Hierarchy tab and find the Main Camera object, then right click on it and select Delete.
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.
By doing this we are fixing the user's position and orientation relative to the floor. The position in VR is calculated based on the user’s height which they indicate when setting up their Rift device.
In other words, regardless of the users of your app, it will adjust to fit every one!
Step 5: Enable Oculus Touch Controllers
Now that we’ve set up our camera, we need to set up the controllers to represent the player’s hands.
If you want the player to use their Oculus Avatar hands, navigate to Oculus > Avatar > Content > Prefabs under the Assets panel
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.
In your Hierarchy Tab, click the LocalAvatar game object. Then, check out the 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!
Step 6: 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 or 1-on-1 packages with expert AR/VR mentor.
And that's it!
Hide your cords out of your way and tighten your velcro straps. Unfortunately the wireless options for Oculus Rift HMD or Rift S. isn't available and Facebook hasn't updated the software for Rift devices in a while. Sorry.
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!
- What's next? If you're just starting out, join one of our live or on-demand VR Workshops. Or if you prefer to get right into it, read our guide on grabbing objects in Unity.Attention: use the latest drivers from Oculus and Unity to support your AR/VR development needs.
- Alternatively, look at out complete 10-week course on XR Development with Unity course syllabus.
- 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 its “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 its “OVR Avatar(Script)” component, make sure the box next to it is checked.
- Save the scene! You now have a project ready to develop for the Oculus Rift!