Quantcast
Channel: Leap Motion Blog
Viewing all articles
Browse latest Browse all 481

Getting Started with Unity (and the Oculus Rift)

$
0
0

Just in time for the 3D Jam, we’ve rolled out an update to our setup guide for Unity, along with a brand-new asset! With Rift/Desktop, your project will be able to recognize whether an Oculus Rift is connected, and set the camera accordingly – allowing for easy access to desktop and VR modes within a single app. Here’s a quick recap of our existing Unity resources, including the new asset.

V2 Core Assets

The core of our V2 skeletal Unity assets is the HandController – a virtual Leap Motion Controller that you can drop directly into your projects. It does the job of placing your hands in Unity space, including managing type and unit conversions. The package also includes several rigged hands, the beta interaction engine, and more.

rigged-hand-form-fuction-unity

robot-chess-oculus-unity-rigged-hand

Form and Function 3D and Robot Chess include different rigged hands to allow users to see their movements in 3D space.

To learn more about how to drop these assets into your project, visit our getting started page to see setup instructions and video tutorials.

Oculus Passthrough vs. Rift/Desktop

We’ve developed VR assets on top of our core assets that you can use to combine Leap Motion interaction with the Oculus Rift. For now, they exist as two separate packages, so you’ll want to use the one that provides the functionality you want.

Oculus Passthrough uses the Image API so that you can use raw infrared imagery in your project along with Leap Motion tracking. Your users’ hands (as well as other nearby objects) will appear in ghostly infrared – as you can see in the Unity3D + Oculus + Leap and Plasma Ball VR demos.

plasma-ball-vr-oculus-unity

Rift/Desktop is our latest Unity asset, featuring a camera management setup makes it possible to switch between the Oculus camera and the Normal camera. By detecting whether or not a Rift is connected, it will set the appropriate camera, so that VR and desktop modes are supported by the same app.

The Rift/Desktop asset also comes with a few examples in the Assets/Example folder:

Download your VR asset of choice on our downloads page.

Building your own Leap Motion + Oculus Prefab

For all you DIYers out there, here are a few key tips for constructing your own Prefab combining the Leap Motion Controller and Oculus Rift:

HandController. This script from our core Unity assets is essential to integrating Leap Motion data with the Unity worldspace. Unless you really want to reinvent the wheel, be sure to have our V2 skeletal assets in place.

Position: 0.032, 0.0, 0.08. By default, the two Oculus cameras are separated by 0.064 (6.4cm in real-world length),* which is the average distance between human eyes. To center it, you need to offset it by 0.032 along the x-axis. Since the Leap Motion Controller in the physical world is approximately 8 cm away from your real eyes, you’ll also need to offset it by 0.08 in the z-axis.

* Note that distances in Unity are measured in meters.

Rotation: 270°, 180°, 0. By default, your virtual Leap Motion Controller is pointing upwards, as if it’s sitting on a table. This means you’ll need to rotate it -90° (or 270°) along the x-axis to make it face forward, then rotate it by 180° along the y-axis to make it upright.

Scale: 1.55, 1.55, 1.55. This is the magic number that will allow the hands created by the Leap Motion Controller to be accurate to Unity space.

Customizing the Oculus Controller. By default, the Oculus asset adds a “neck” length. If you want to center the cameras and Leap Motion Controller at a very specific spot within Unity, make sure to disable “Use Player Eye Height” and set “Camera Root Position” to (0,0,0). This will ensure the Oculus cameras are at localPosition (0,0,0).

What sorts of Unity resources would you like to see next? Let us know in the comments!

The post Getting Started with Unity (and the Oculus Rift) appeared first on Leap Motion Blog.


Viewing all articles
Browse latest Browse all 481

Trending Articles