Unity How-to Guide : Motion Tracking

This Motion Tracking How-to guide will get you up and running with a simple Motion Tracking application in Unity. The instructions are intended for Unity developers of any experience level. You'll add a Tango-enabled camera, and then build a simple scene. When you launch your app and then walk around in your environment, the device's motion moves the camera around in the Unity scene.

If you are a more experienced Unity developer, you may also want to review the code samples in GitHub and the SDK Reference Documentation.

Preliminary steps

  1. If you haven't set up your computer to develop with Tango in Unity yet, see Getting Started With Unity.

  2. Go to the Setup for All Unity Tango Apps page and perform the basic setup operations on that page. When you have finished, return to this page and continue on with the steps below.

Add the Tango Camera prefab to your Hierarchy

If you want to learn more about prefabs, see the Unity documentation.

  1. In the Project panel, click TangoPrefabs to view the contents of that folder.
  2. Drag the Tango Camera prefab to the Hierarchy panel.

Add gameObjects

  1. Select GameObject > 3D Object > Cube.
  2. From the same menu, add a Plane and a Sphere gameObject.

Adjust the positions of the gameObjects

Adjust the positions of the following gameObjects by changing their Position (XYZ) values. These values are found in each gameObject's Transform component. Change each gameObject as follows:

  • Cube: position = 3,1,0.
  • Sphere: position = 0,1,3.
  • Tango Camera: position = 0,1,0.

The default values of the plane and directional light will work fine. Here they are in case you'd like to confirm them:

  • Plane: position = 0,0,0.
  • Directional light: position = 0,3,0.

Your scene should look something like this:

Build and run your project

  1. On the File menu, click Build and Run.
  2. In the Build Settings dialog, click Build and Run.
  3. In the Build Android dialog, enter a name in the Save As field, and then click Save.

Experiment with your app

Hold your device up to eye level. You should see the sphere. Start to walk around, and note that your movement in the real world is duplicated in the virtual world of your app. Walk to the left and right of the sphere, and behind it. If you tilt your device back and forth and move it around enough, you'll eventually see the cube.

Send feedback about...

Tango Unity SDK
Tango Unity SDK