Search code examples
c#unity-game-engineaugmented-realityvuforia

Vuforia: image sticks to the screen when the marker is lost


When Vuforia loses the marker, the 3D model which was "attached" to the marker is sticking to the screen. How to make it disappear if the marker tracking is lost?


Solution

  • Look for the script where you have:

    public void OnTrackableStateChanged(
                                    TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED ||
            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            OnTrackingFound();
        }
        else
        {
            OnTrackingLost();
        }
    }
    

    Then, implement OnTrackingLost:

    void OnTrackingLost()
    {
         model.SetActive(false);
    }