Introduction to Model Targets in Unity

Animated gif using Unity and Model Targets

Introduction

This guide walks developers through the process of placing content onto objects that are recognized by their geometry using Vuforia’s Model Targets. For more information on Model Targets, please refer to the Model Targets User Guide. We recommended developers to leverage the Positional Device Tracker for optimum performance. Please refer to Positional Device Tracker for more information.

Creating your first Model Target Experience

  1. Open Unity 2017.3 or newer
  2. Create a New Project
  3. In the Edit Menu select: Project Settings> Player. In the “XR Settings” section of the PlayerSettings, make sure that “Vuforia Augmented Reality Supported” is checked.
Vuforia Image
  1. Replace the default “Main Camera” with an ARCamera. In the Game Object Menu select: Vuforia> AR Camera to create a new AR Camera object in the scene. Remove the default “Main Camera” from the scene.
  2. Create your Model Target Database using the Model Target Generator tool. Please refer to the Model Target Generator User Guide for instructions on creating your Model Target Database. The Model Target Generator will generate a *.unitypackage file
  3. Import the Model Target Database package. In the Assets menu, select: Import Package> Custom Package… and select the *.unitypackage file created in the previous step
  4. Obtain a License Key for your project. Please refer to the Vuforia License Manager guide on how to obtain a Vuforia 7 license key. Licenses generated with a previous version of Vuforia will not work with Model Targets. Note: A license key is not necessary when using the default Viking Lander model
  5. Open the Vuforia Configuration window (Window menu, select “Vuforia Configuration”) and expand the "Global" section to paste in your app license key
Vuforia Image
  1. In the GameObject menu, select Vuforia>Model Target to create a Model Target game object in your scene.
Vuforia Image
  1. Select the ModelTarget GameObject in the Scene Hierarchy window. In the Inspector window, be sure to select the appropriate Database and Model Target in the Model Target Behaviour component. It is also important to make sure that the physical dimensions of your real-world object matches the Model Target Physical Length, Width and Height. Please consider this if you are developing on a scaled model of a much larger real-world object.  Also note that the size is in meters.
Vuforia Image
  1. Also in the Model Target Behaviour component, set the “Guide View Mode” to “Guide View 2D”
Vuforia Image
  1. You will notice that in your scene there is a preview model of the Model Target. This preview model is only visible while in the Scene view of the Unity Editor. This allows you to place content relative specific areas of your Model Target
Vuforia Image
  1. Attach a standard webcam to your computer and press the “Play” button in Unity. Alternatively, you can deploy to your device.
  2. In play mode or on device, you will notice the outlined guide view of your 3D object – this is the Guide View

Vuforia Image
  1. Align the Guide View with your real-world object. You will notice the Guide View disappear.
  2. To customize your AR experience, place your custom content as a child of the ModelTarget game object.
Vuforia Image
  1. Align your content relative to the preview model
Vuforia Image
  1. Again, with a standard webcam attached to your computer, press the “Play” button in Unity. Alternatively, you can deploy to your device. Once you align the Guide View, you will see your augmentation
Vuforia Image

 

To add advanced occlusion functionality to your applications, refer to the Unity Asset Store.