Skip to main content
Version: 12 Dec 2024

Handling Tracking Loss

If the Magic Leap can't locate its position in an environment, it experiences "tracking loss". The Magic Leap 2 lets developers manage their own tracking loss behavior -- some developers may want to pause the update loop and display a splash image, while others may want the app to continue playing.

If tracking is lost and cannot be recovered for 15 seconds, Magic Leap 2 will reset its tracking origin the next time tracking is recovered. The origin is reset to avoid virtual content from appearing in the incorrect location.

Head Pose / Origin Reset

This example shows how to listen to the OnTrackingOriginChanged event.

    private void Start()
{
XRInputSubsystem inputSubsystem = XRGeneralSettings.Instance?.Manager?.activeLoader
?.GetLoadedSubsystem<XRInputSubsystem>();
if(inputSubsystem !=null )
inputSubsystem.trackingOriginUpdated += OnTrackingOriginChanged;
}

private void OnDestroy()
{
XRInputSubsystem inputSubsystem = XRGeneralSettings.Instance?.Manager?.activeLoader
?.GetLoadedSubsystem<XRInputSubsystem>();
if (inputSubsystem != null)
inputSubsystem.trackingOriginUpdated -= OnTrackingOriginChanged;
}

/// Use event to detect if a new session occurs
/// <param name="inputSubsystem"> The inputSubsystem that invoked this event.</param>
private void OnTrackingOriginChanged(XRInputSubsystem inputSubsystem)
{
//...
}