# Building with Leap Motion

## Requirements

<table data-view="cards"><thead><tr><th></th><th data-type="content-ref"></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Looking Glass Bridge</td><td><a href="../software/looking-glass-bridge">looking-glass-bridge</a></td><td>The connection between your computer and your Looking Glass.</td><td><a href="https://content.gitbook.com/content/PuCaeVAli72TiclYlEG5/blobs/9GkLra3t3Nd7T2pdjW0b/gitbook_bridge_card.webp">gitbook_bridge_card.webp</a></td><td><a href="https://lookingglassfactory.com/software/looking-glass-bridge">https://lookingglassfactory.com/software/looking-glass-bridge</a></td></tr><tr><td><a href="https://unity.com/"><strong>Unity</strong></a></td><td></td><td></td><td></td><td></td></tr><tr><td><a href="https://developer.leapmotion.com/tracking-software-download?_gl=1*1iwhdep*_ga*MTAxNjYwMjI3Ny4xNjc5NjU4NzMw*_ga_5G8B19JLWG*MTcwMTQ2NDU3NC4yNi4xLjE3MDE0NjQ1ODAuNTQuMC4w">Ultraleap Gemini Hand Tracking Software</a></td><td></td><td></td><td></td><td></td></tr></tbody></table>

## Introduction

In this tutorial we'll go over how to setup your Leap Motion Device in Unity and try out one of the cool demos we've put together! In order to follow this tutorial, the Leap Motion Controller needs to be plugged into your PC, and your Looking Glass display needs to be set to Desktop Mode.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/62f5ac7f764027f0ff0e9538_LeapMotion.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/PuCaeVAli72TiclYlEG5/blobs/Etq974BYwcqX9nZmLYPc/docs-divider-gradient-stroke.png" alt=""><figcaption></figcaption></figure>

## The Types of interactivity <a href="#the-types-of-interactivity" id="the-types-of-interactivity"></a>

So, before we get too in depth in Unity, we want to touch on different kinds of interactions you can make with leap motion. There are two main methods of adding interaction, one has to deal with physics, and the other with proximity.

### Physics

Physics interactions can be super fun, they're very useful for getting engagement out of your users and can be a great first experience with hand tracking! Physics tend to be easier to setup, so if you're new to leap motion & unity this is the place you'll want to start.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/63068cd420e4ad6e1768f785_ezgif.com-gif-maker%20(8).webp" alt=""><figcaption></figcaption></figure>

### Proximity

Proximity Interactions can be useful for things like buttons, UI, turn tables or anything you want to have a bit more precision over than with the physics assets.&#x20;

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/63068bc417bbfb322cb8ade9_ezgif.com-gif-maker%20(7).webp" alt=""><figcaption></figcaption></figure>

Proximity Interactions use the location of fingers, or the leap hands combined with raw values like speed, or velocity to create motion or trigger an event. This makes proximity interactions more complex than physics interactions in terms of setup, but they're much easier to work with for UI you'll be interacting with often.

<figure><img src="https://content.gitbook.com/content/PuCaeVAli72TiclYlEG5/blobs/Etq974BYwcqX9nZmLYPc/docs-divider-gradient-stroke.png" alt=""><figcaption></figcaption></figure>

## Technical Setup in Unity

> 💡 The Leap Motion SDK is best used with Unity 2019.4 LTS currently. Please ensure you're using that version of Unity before getting started.

### 1. Install the Leap Motion Unity Packages

Before we get started making cool interactions we'll need to install the Leap Motion & HoloPlay Unity Packages.\
Make sure to grab the latest unity package from the links in the required software section at the start of this tutorial. Note that Leap's software SDK for unity consists of three unity packages, we'll want to install all of them for this project.\
\
You can install the unity packages by going to the add menu in Unity, then selecting import package.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/62e3f550ca2a2c28a92a1ea9_unity-package-installation.png" alt=""><figcaption></figcaption></figure>

‍

After you've installed the Unity Packages, you should see the following folders in your asset browser. The HoloPlay & HoloPlay Plugins folders contain everything you need to use your Looking Glass, & the Plugins folder contains all the Leap Motion tools.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/62e3f550216b054616b88acf_asset-browser.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/PuCaeVAli72TiclYlEG5/blobs/Etq974BYwcqX9nZmLYPc/docs-divider-gradient-stroke.png" alt=""><figcaption></figcaption></figure>

### 2. Add Leap Motion Hands to your scene

The easiest way to add leap motion to your scene is to duplicate the capsule hands example demo from: Plugins\LeapMotion\Core\Examples\
\
From there you can either copy the scene into your existing scene or work straight out of the copy by adding a HoloPlay Capture to the leap capsule hands scene.

**The reason we're duplicating the scene is so we don't overwrite the original if we want to make a new scene with it later.**

> 💡 you can add a HoloPlay Capture to your scene really quickly by right clicking in your scene graph and choosing "HoloPlay Capture" from the menu!

With our scene now open we should see a leap motion gizmo in the scene, along with a few leap motion specific items. Let's go over some of the basics of setting up our scene.\
\
1\) So the first thing you'll probably notice is that the HoloPlay Capture is rather large compared to the leap hands, I typically set the HoloPlay Capture's Size variable to around 0.75 to make the hands larger, but this can be up to you, any size will work as long as the hands are in the HoloPlay capture volume.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/62e3f55068cd9dcbfeb03452_basic-unity-setup-with-leap-motion.png" alt=""><figcaption></figcaption></figure>

‍

2\) The second thing you'll want to change is the tracking settings on the **Leap Hand Controller** object. By default, this is set to "screen top" but you'll want to change this to "**Desktop Mode A**" in the object's Inspector panel.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/62e3f55068cd9d5bd4b03450_leaphandcontroller_settings.png" alt=""><figcaption></figcaption></figure>

‍

3\) You'll also want to modify the rotation of the Leap Motion, since we are using it in up facing mode flat on our desktop, you'll want to make sure the rotation is zeroed out for now.

<figure><img src="https://assets-global.website-files.com/62b1e7ca6ca42995253b6d61/62e3f55090f07374e084cfb2_leap-motion_orientation_correct.png" alt=""><figcaption></figcaption></figure>

‍

Now that we've done all that we should be set to get started with previewing our hands! Click the "Play" button and hit CTRL + E to toggle the preview window on the Looking Glass.

<figure><img src="https://content.gitbook.com/content/PuCaeVAli72TiclYlEG5/blobs/Etq974BYwcqX9nZmLYPc/docs-divider-gradient-stroke.png" alt=""><figcaption></figcaption></figure>

### 3. Setting up Physics with Springs

In this video we'll walk you through how to setup spring physics and how springs work in Unity, along with some general tips on testing values quickly & working with live preview in Unity.

{% embed url="<https://vimeo.com/655471227/995557f520>" %}

### 4. The Importance of Lighting & Shadows

How your scene is lit & how shadows are cast are super important to a good experience, check out this short video to learn more how a few properly spaced spot lights can make the world of difference!&#x20;

{% embed url="<https://vimeo.com/655132127/da81d008c0>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lfdocs.lookingglassfactory.com/community/using-leap-motion-with-looking-glass.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
