VR Setup

The Leap Motion Core Unity Assets provide the LMHeadMountedRig prefab which provides a complete camera and hand controller setup for both Virtual and Augmented Reality scenes. This prefab allows simple configuration to use either images from the Leap Motion cameras or 3D models to represent your hands.

The scripts in the LMHeadMountedRig automatically adjust the stereo camera positions to the correct interpupillary distance and automatically compensate for video lag in AR scenes.

Note that the Oculus Rift no longer supports OS X as of version 0.7 of the Oculus runtime. If you are developing on a Mac, and thus using an earlier version of the Oculus runtime, you should use version 2.3.1 of the Leap Motion core assets. See Using the Image Hand Assets in version 2.3.1 for information on using images for hands in version 2.3.1.

To set up a Virtual or Augmented Reality scene in Unity:

  1. Open or create a new project in Unity.

  2. Enable Unity Virtual Reality support

    1. Display the Player settings with the Edit > Project Settings > Player menu command.

    2. Under Other Settings category, check Virtual Reality Supported checkbox.

      https://di4564baj7skl.cloudfront.net/documentation/v2/images/unity/Unity_VR_PlayerSettings.png
  3. Open or create a new scene.

  4. Delete existing, unwanted cameras.

  5. Drag the LMHeadMountedRig prefab into the scene from the Assets/LeapMotionVR/Prefabs folder.

    https://di4564baj7skl.cloudfront.net/documentation/v2/images/unity/Unity_VR_LMRig.png
  6. Set the position and orientation of the rig as appropriate for your scene.

  7. Set the configuration option. The choices are:

    • VR World VR hands – An opaque 3D world with 3D model hands.
    • VR World AR hands – An opaque 3D world with camera image hands.
    • AR World AR hands – The camera images are used as the backdrop for the 3D world as well as for the hands.
  8. If you are using the VR hands option, assign your desired hand prefabs from the Assets/LeapMotion/Prefabs folder.

    Note that you can also set the hand prefabs, as well as the physics hand prefabs, directly on the HandController component — which is nested deeply inside the LMHeadMountedRig object. Note that changing the selected configuration will reset all the hand models — as will clicking the “Reapply Selected Configuration” button

  9. Press Play button to test.

    https://di4564baj7skl.cloudfront.net/documentation/v2/images/unity/Unity_VR_Playing.png
  10. Save the scene.

You can now add other elements to the scene as desired.

Improving Hand Presence

The ThresholdOverlay shader can be used to improve the sense of hand presence in a scene when using the AR hands. This shader makes bright objects seen by the infrared cameras remain visible, even if they’re not fully recognized as hands. You can assign this shader to an overlay quad that is composited over the scene. For instructions, see How to Unlock Maximum Hand Presence with Image Hands.

We plan to use this shader by default in a future release of the asset package.