Oculus Rift DK2
Note: The following demo is provided by the makers of the Oculus VR DK2 headset and Unity Pro 4.5 or later. It is available to all developers through the oculus rift website. Kindly register (free) for the complete SDK. (The integration package is a modified version from the original oculus wrapper (v0.4.2 Beta).)
What is the Oculus Rift?
- You do not need the SDK to run Unity and Oculus together. Just download the wrapper listed at the end of this page.
- Open a new unity project. Go to Assets -> Import Package -> Custom Package and choose the OculusUnityIntegration.unitypackage located in OculusUnityIntegration folder.
- After import, you will find two folders, OVR and Plugins, are created under Assets.
- In OVR, there is a Prefabs folder. Drag the OVRCameraController to your scene or OVRPlayerController based on what you want to use.
(Note: The OVRPlayerController is written over the character controller, you might want to write your own controller)
Positional Head Tracking
One of the key technical breakthroughs Oculus Rift DK2 features is that it provides precise, low-latency positional head tracking. Here are some tips for using positional head tracking feature:
- Check the Enable Position in OVRCameraController is on.
- DK2 use its position tracking camera to track user's head position. You can add OVRMainMenu(under OVR\Scripts) script component to OVRCameraController in order to add a reminder once user goes outside the camera's tracking frustum. Remember to assign a texture to the Fade In Texture variable. (You can just use the Black texture file locates at OVR\Textures.)
- Adjust the scale parameter in OVRCameraController's Transform component to magnify/reduce the feedback of user's physical movement in certain direction axis.
- Reset the cameras position to where OVRCameraController is by calling
OVRCamera.ResetCameraPositionOrientation(Vector3.one, Vector3.zero, Vector3.one, Vector3.zero);
- in your script. By doing so, you can make sure each guest will start from the same position in your virtual world, no matter what the relative position between your guest and the tracking camera is.
OVRCameraController component is the main interface between Unity and the cameras. All camera control should be done through this component. Under OVRCameraController, you can find
- IPD: Interpupillary Distance for the cameras (in meters). IPD calibration is important for nausea-free gameplay with the Oculus Rift. The default is set to either the average IPD value, or to the value that has been set by the Oculus Configuration Utility.
- Follow Orientation: The camera will follow the input Transform's orientation, and the head-tracking will be an offset of this. This is useful for mounting the camera on a rigid object, such as a car.
- Tracker Rotates Y: When set, the actual Y rotation of the cameras will set the Y rotation value of the parent transform that it is attached to. NOTE: Setting Follow Orientation with the parent transform of this component and setting Tracker Rotates Y to True will cause a feedback loop in orientation.
- Mirror to Display: Turn it on to show an additional audience window on desktop if the executable runs under Oculus Direct Display mode.
- Resolution should be set as 1920*1080.
- In Supported Aspect Ratios, only check 16:10 and 16:9.
- In Quality Settings (Edit -> Project Settings -> Quality), set Anti Aliasing as 4X or higher is ideal.
- Instead of using "Build & Run" directly, use "Build" to build your project (<YourApp>.exe) and then run the <YourApp>_DirectToRift.exe file produced by the build.
Set up DK2 on New Computer (Windows)
In order to use Oculus Rift DK2 on your computer for demo, you should follow the following steps:
- Download and install official Oculus Runtime for Windows. Please use the one which matches with the version of DK2 Unity wrapper.
- Restart the computer and follow the instructions of official Developer Guide to connect Oculus Rift and position tracking camera to the computer.
- Open Oculus Configuration Utility -> Tools -> Rift Display Mode, and set Display Mode as Direct HMD Access from Apps mode.
- The Rift shows nothing while running <YourApp>_DirectToRift.exe under Direct-Mode.
- Close your application, and then go to Oculus Configuration Utility, open Rift Display Mode window (by following Tools -> Rift Display Mode).
- Switch to Extend Desktop to the HMD and press Apply.
- After the power light of the Rift becomes blue and you can see the desktop through the Rift, go back to Rift Display Mode window and switch back to Direct HMD Access from Apps mode.
- Run <YourApp>_DirectToRift.exe file.
- The Rift seems disconnected while clicking Play in Unity Editor. That is, Instead of tracking Rift's movements and orientations, cameras just freeze there in the scene. [Note: This might happen if you forgot to turn on the Rift before clicking Play.]
- Close Unity Editor.
- Go to Oculus Configuration Utility and open Rift Display Mode window (by following Tools -> Rift Display Mode).
- Switch to Extend Desktop to the HMD.
- Open your Unity project and click Play. Now, Unity Editor should track the Rift's movements correctly.
- Stop Play in Unity Editor. Go back Rift Display Mode window and switch back to Direct HMD Access from Apps mode.
- [Note: Oculus Rift's screen won't display anything by clicking Play in Unity Editor.]
- PS Move seems disconnected while running the <YourApp>_DirectToRift.exe file. [Note: This might happen when it's the first time you try to run <YourApp>_DirectToRift.exe directly on the computer.]
- Close your <YourApp>_DirectToRift.exe file.
- Run <YourApp>.exe and allow the access in Windows' security alert.
- Close <YourApp>.exe and run the <YourApp>_DirectToRift.exe file.