Using the Device Tracker in Unity

Vuforia Engine supports the development of various interactive AR and VR experiences through the use of the Rotational and Positional Device Trackers. The Device Tracker provides rotational and/or positional information about where the device is relative to the world. The Rotational Device Tracker is optimal for VR or AR applications that need to leverage 3 degrees-of-freedom. The Positional Device Tracker is great for AR applications that need to put content in the environment or want to provide additional robustness to Target tracking with 6 degrees-of-freedom.

This article describes the use of the Device Tracker in Unity. If you are developing an application for native Android or iOS, see Using the Device Tracker document.

Using the Positional Tracker for AR

This section shows how to enable the Positional Device Tracker for AR applications. The Positional Device Tracker is required for the Ground Plane feature. In addition, the Positional Device Tracker enables "Extended Tracking" on all of Vuforia Engine's Targets. Device Tracking is highly recommended for Model Target objects.

  1. In the Vuforia Configuration Inspector (menu: Window>Vuforia Configuration), Select "POSITIONAL" under Tracking Mode. By default, the Fusion Mode is set to "Optimize for Model Targets and Ground Plane". This mode is required for developers looking to use Ground Plane and highly recommended for Model Targets.
Vuforia Image
  1. Developers that do not need to use Ground Plane or Model Targets and want Extended Tracking functionality should consider using "Optimize for Image Targets and VuMarks" which optimizes the Device Tracker for Image Targets, VuMarks, Cylinder Targets, Multi-Targets, Object Targets and User Defined Targets.   
Vuforia Image
  1. Developers can also turn Device Tracking On and set the Fusion Mode through code:
    void Awake() 
    { 
        VuforiaARController.Instance.RegisterVuforiaInitializedCallback(OnVuforiaInitialized); 
    } 
    
    void OnVuforiaInitialized() 
    { 
      VuforiaConfiguration.Instance.DeviceTracker.FusionMode = FusionProviderType.OPTIMIZE_IMAGE_TARGETS_AND_VUMARKS;
      var deviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();
      deviceTracker.Start();
    } 
    

Using the Rotational Tracker for VR

This section shows how to configure a Vuforia Unity app in the Unity Editor to use rotational device tracking. You can also enable rotational device tracking programmatically using the MixedRealityController, See: Using the MixedRealityController in Unity

Note that Rotational Device Tracking is only supported for VR Mode experiences and is not compatible with AR experiences that utilize target tracking.

 

1. Select DEVICE as your World Center Mode in the ARCamera's Vuforia Behaviour component.

Vuforia Image

2. Select which pivot correct model to use ( HEAD || HANDHELD || NONE ) in the Vuforia Configuration Inspector (menu: Window>Vuforia Configuration). The correction model applies a rotational offset appropriate to either Head and Hand tracking.

Vuforia Image

You can also define your own rotational offset by selecting Custom model transform.

Vuforia Image

3. If your app is using a viewer and performing head tracking select "Phone + Viewer" as the Device Type in the Vuforia Configuration window, then select the Viewer Config and Viewer Type that your app is using

Vuforia Image

4. If you are using the "Vuforia" Viewer Config for "Phone + Viewer" or the "Vuforia"  Device Config for "Digital Eyewear", then you must configure the appropriate device in Unity's XR setting configuration.

IMPORTANT: Make sure that the "Vuforia" Virtual Reality SDK comes after the appropriate device SDK. The order is important!

Vuforia Image