Enable Device Tracking in Unity

Vuforia Engine supports the development of AR experiences that interact with the environment through Device Tracking. Device Tracking provides information about where the device is relative to the world. It enables AR applications that need to place content in the environment or want to provide additional robustness to target tracking in case the target is occluded or not fully in view.

This article describes how to enable and use Device Tracking in Unity. If you are developing an application for native Android or iOS, refer to the Enable Device Tracking in Native article.

Device Tracking in Unity

When creating a new Unity project and importing the Vuforia Engine, Device Tracking is enabled by default in any of your scenes. The Device Pose Behaviour is automatically added to the ARCamera game object. It will enable the Ground Plane and Area Target features and it is recommended for Model Targets. In addition, device tracking enables Extended Tracking for all target types and it is also used to recover tracking from application interrupts as outlined in Vuforia Continued AR Experiences.

Enable/disable the Device Tracker

  1. In the ARCamera GameObject’s Inspector window, click Vuforia Configuration.
    The VuforiaConfiguration Inspector window opens.
  2. Expand the Device Tracker section and toggle the Track Device Pose.
    If you are using a device tracking dependent Vuforia feature, disabling Device Tracking will cause errors.

Use the Tracking Status to enable Extended Tracking for individual targets

Configure the target’s status in the Unity Editor via the Default Observer Event Handler. Choose if the target should render content when it is TRACKED, EXTENDED_TRACKED or also while a LIMITED pose is available. This allows for per-target configuration of extended tracked poses.

If a target is reported with status LIMITED, only an inaccurate pose is available. It should only be taken into consideration if close alignment of virtual content and real-world object is not required.

Please refer to Status Poses and Status Info for more information on handling the status poses and status info.

Static Device Tracking

In some scenarios, the device may be statically mounted (e.g. on a tripod) instead of being handheld, which can fail to to initialize the Device Pose Behaviour due to lack of device motion. In such use cases, you can set a static hint for the Device Pose. The hint will set the Device Pose in a static mode that ensures that extended tracking and robustness against occlusions work even when the device is fixed to one position. Setting the Device Pose Observer’s SetstaticMode() to true resets and re-initialize the device tracking. See SetStaticMode for the detailed behaviour.

void Awake()
    VuforiaApplication.Instance.OnVuforiaStarted += OnVuforiaStarted;
void OnVuforiaStarted()

This hint needs to be set before Vuforia Engine has started. 
In a scene with an ARCamera this is best done by calling this method from an Awake function.

Android specific Device Tracking Settings

When developing a Unity application for Android, enable ARCore on supported devices that have it installed. The following explains the options available in the Android Settings section:

By default, the ARCore Requirement dropdown is set to OPTIONAL. In this mode, Vuforia Engine uses VISLAM or SLAM on devices that do not support ARCore. Set the dropdown to REQUIRED to indicate that the app can only be installed on Android devices that support ARCore. Set the dropdown to DON’T USE to indicate that the app will not use ARCore.

If OPTIONAL or REQUIRED are selected, then ARCore is enabled and Vuforia Engine requires that the ARCore client library is packaged with the application so that ARCore functionality can be accessed at runtime. Select Include ARCore library to automatically include the latest supported library version. This is only supported when using Gradle to build the application.

If Include ARCore library is disabled, then the developer needs to package the ARCore client library with the app by including it in the Plugins/Android folder of the Unity project.

For more information, refer to the Enable ARCore article.

Can this page be better?
Share your feedback via our issue tracker