The LMHeadMountedRig prefab is a full VR rig that combines cameras and hand tracking.

This prefab is designed to work with Unity’s built-in VR Support. If you are using a VR SDK directly, you will typically need to add the requisite Leap Motion components to the VR camera rig provided by your VR SDK. You will also need to do this if the LMHeadMountedRig does not suit your scene in other ways, such as if you are using a character controller with its own cameras.

Using the LMHeadMountedRig

To use the LMHeadMountedRig to a scene:

  1. Remove any existing camera or camera rigs.

  2. Drag the prefab into the scene hierarchy.

  3. Position the prefab in the scene. Like any VR camera, the position and orientation of the rig will be the initial view of the scene (as modified by the HMD tracking system).

  4. Add your hand models to the Hand Pool in the LeapHandController component:

    1. Select the LeapHandController in the hierarchy.
    2. Set the Hand Pool’s Model Pool size to 2. This will create two elements in the pool.
    3. Set the name of one element to “gfx_hands” (or any suitable name).
    4. Drag the desired hand prefabs to the left and right model properties.
    5. Set Is Enabled and Can Duplicate to true.
    6. Repeat for the second element, using physics hand prefabs.

    You can use prefabs directly in the hand pool or place the hand models in the scene hierarchy first. If you place the hand models in the scene, note that we no longer recommend placing the models as children of the LeapHandController. The models should go outside the camera hierarchy. Otherwise stuttering can occur during head movement.

Key Components

The LMHeadMountedRig contains the following key components:

VR Height Offset

Use the VR Height Offset component to compensate for differences in how different HMD systems determine the starting height of the VR cameras in a scene. The VR Height Offset component adjusts the height of the camera rig at scene startup using the configured offset value. By default, the component contains an offset for the Oculus Rift. If you need to create an offset for a different device, add an additional record to the component instance on the LMHeadMountedRig game object. (To add the device offset to all instances, you can extend the VRHeightOffset script itself.)

The Device Name must match the value returned by the Unity VRSettings.loadedDeviceName API (case does not matter).

Leap VR Camera Control

The default settings are typically correct for the default LMHeadMountedRig as used in a VR scene. (For an AR scene, you should check Override Eye Position, but note that additional changes are required to the rig to use it in AR.)

Leap VR Temporal Warping

The Leap VR Temporal Warping component interpolates the position of the cameras to compensate for differences between the captured Leap Motion frame time and the current Unity update time.

The component provides the following settings:

  • Recenter – sets the keyboard key used to trigger the Unity TrackingInput.Recenter() function.

  • Tween Image Warping – identifies the amount of warping to apply to images: 0 means no warping is applied, 1 is full warping.

  • Tween Rotational Warp – identifies the amount of rotational warping to apply to the cameras.

  • Tween Positional Warping – identifies the amount of translational warping to apply to the cameras.

  • Sync Mode – determines when temporal warping takes place:

    • LOW_LATENCY – performs the time warp during OnPreCull, which is as late in the execution order as possible.
    • SYNC_WITH_HANDS – performs the time warp in the LateUpdate.
  • Allow Manual Time Alignment – allows manual adjustment of the warp time and reveals the following settings:

    • Warping Adjustment – the amount of manual adjustment, in milliseconds, to add to the calculated warp time. A positive value adjusts the time warp further into the past.
    • Unlock Hold – sets the keyboard key modifier that must be held down for the other rewind keys to work.
    • More Rewind – sets the keyboard key to adjusts the warp time further back in time. Each kestroke changes the adjustment by 1ms.
    • Less Rewind – sets the keyboard key to adjusts the warp time further forward in time.

Leap Service Provider

The Leap Service Provider is the connection point between the Leap Motion service and the rest of the Unity assets. The service provider gets frames and images from the service and provides them other parts of your application.

  • Is Head Mounted – must be enabled for proper hand tracking when the Leap Motion hardware is mounted on an HMD. Must be unchecked when using the Leap Motion hardware in a desktop (facing upward) configuration.
  • Override Device Type – enables the use of a specific Leap Motion hardware profile. Typically, this should be left unchecked.
  • Override Device Type With:
    • Peripheral – the standard device.
    • Dragonfly – an internal prototype device. Should only be used if you have one of the handful of these devices that exist in the world.
  • Use Interpolation – enables frame interpolation/extrapolation. When enabled, the service provides a frame of data interpolated or extrapolated to match the actual time when the Unity Update or FixedUpdate events are executed.
  • Interpolation Delay – adjusts the interpolation time by a fixed amount. Too small a delay can lead to excessive extrapolation, which can be recognized by jerkiness in the hand and finger movements. Too large a delay will add excessive latency.

Hand Pool

The Hand Pool manages the representation of the hands in a scene. A single tracked hand can have any number of task-specific Unity game objects associated with it. For example, one representation might be for the graphics display, one for the physics interactions, and another for attaching utility objects to the hand.

Each of these task-specific hand game objects must be added to the hand pool in a separate pool element (as described in Using the LMHeadMountedRig). Each element in the pool must have a game object for both the left and right hands

Increase the Model Pool Size to add additional elements. For each element in the pool you can make the following settings:

  • Group Name – an arbitrary string you can assign to identify the group when calling the EnableGroup() and DisableGroup() functions of the HandPool object.
  • Left Model – the game object or prefab to use for left hands.
  • Right Model – the game object or prefab to use for right hands.
  • Is Enabled – whether this group is currently enabled. You can change this setting in the Unity Editor or at runtime with the EnableGroup() and DisableGroup() HandPool functions.
  • Can Duplicate – determines whether more than one instances of these game objects can exist in the scene. For example, if there are more than one left or right hand in a scene because the Leap Motion software misidentifies the chirality of a hand or two different people place hands in view, then an additional hand model is spawned when Can Duplicate is true. When false, only the first hand in view would be represented by a model from this group.