Unity Plugin Overview

The Leap Motion Controller tracks hands and fingers and reports position, velocity, and orientation with low latency and good accuracy. The controller can be used on a tabletop or mounted on a VR headset.

The Leap Motion controller system consists of a hardware device and a software component which runs as a service or daemon on the host computer. The software component analyses images produced by the hardware and sends tracking information to applications. The Leap motion Unity plugin connects to this service to get data. Scripts included with the plugin translate Leap Motion coordinates to the Unity coordinate system. These scripts and additional graphic assets make it easy to add 3D, motion-controlled hands to a Unity scene.

Coordinate Systems

Unity3D uses a left-handed convention for its coordinate system, wheras the Leap Motion API uses a right-handed convention. (Essentially, the z-axis points in the opposite direction.) Unity also uses a default unit of meters, wheras the Leap Motion API uses millimeters. The plugin scripts internally transforms the tracking data to use the left-handed coordinate system and scales distance values to meters.

https://di4564baj7skl.cloudfront.net/documentation/v2/images/unity/Unity_Axes.png

The Unity left-handed coordinate system superimposed on the Leap Motion device in its desktop orientation.

https://di4564baj7skl.cloudfront.net/documentation/v2/images/unity/HMD_Unity_Axes.png

The Unity coordinate system superimposed on the Leap Motion device in its HMD orientation.

When you get tracking data directly from one of the classes in the Leap C# library, the data are in the native Leap coordinate system – not the Unity coordinate system. You can use the utility functions in the LeapUnityExtensions file to convert from Leap Motion coordinates to Unity coordinates. ToUnity() converts the axes from right-handed to left-handed and returns a Unity Vector3 object. ToUnityScaled() also scales the coordinates from milimeters to meters. ToUnity() is typically used with direction vectors; ``ToUnityScaled() with positions.

Hand Tracking

The Leap Motion controller uses optical sensors and infrared light. The sensors have a field of view of about 150 degrees. The effective range of the Leap Motion Controller extends from approximately .03 to .6 meters above the device (1 inch to 2 feet).

https://di4564baj7skl.cloudfront.net/documentation/v2/images/Leap_View.jpg

The Leap Motion controller’s view of your hands in desktop mode

Detection and tracking work best when the controller has a clear, high-contrast view of an object’s silhouette. The Leap Motion software combines its sensor data with an internal model of the human hand to help cope with challenging tracking conditions.

https://di4564baj7skl.cloudfront.net/documentation/v2/images/VR-distance.png

Particularly in HMD mode, you should ensure that there is less distance between the sensor and your hands then between your hands and any background objects or walls.