Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

[ARFoundation3] AR Tracked Image Manager not working as expected...

Discussion in 'AR' started by Aaron-Meyers, Nov 15, 2019.

  1. Aaron-Meyers


    Dec 8, 2009
    I've got my image tracking properly, but it never seems to get removed. My setup is simple, just one tracked image. Here is the function I use to handle the trackedImagesChanged event:
    Code (CSharp):
    1. private void OnTrackedImagesChanged( ARTrackedImagesChangedEventArgs eventArgs )
    2. {
    3.     if ( eventArgs.added.Count > 0 )
    4.     {
    5.         var tracked = eventArgs.added[0];
    6.         _startBeacon.SetActive( true );
    7.         _startBeacon.transform.position = tracked.transform.position;
    8.         _startBeacon.transform.rotation = tracked.transform.rotation;
    9.         Logger.Add( "Touch the green beacon!" );
    10.     }
    12.     if ( eventArgs.updated.Count > 0 )
    13.     {
    14.         var tracked = eventArgs.updated[0];
    15.         _startBeacon.transform.position = tracked.transform.position;
    16.         _startBeacon.transform.rotation = tracked.transform.rotation;
    17.     }
    19.     if ( eventArgs.removed.Count > 0 )
    20.     {
    21.         _startBeacon.SetActive( false );
    22.         Logger.Add( "Tracked image lost!" );
    23.     }
    24. }
    The "added" if statement runs once when it first detects the tracked image, but if I remove the image from view, the "removed" if statement is never triggered.

    Am I misunderstanding how this event is meant to be used? Anyone else have this issue?
  2. Aaron-Meyers


    Dec 8, 2009
    Ok... I was going to report a bug on the GitHub repo for ARFoundation samples, but I discovered that there are already two different threads (one & two) discussing the issue, which is present an ARFoundation 2 and 3, going back months ago and it remains unresolved.

    It seems to me that the life cycle of an ARTrackedImage is fundamentally broken since it never appears in the "removed" list when the image is no longer tracked and it never reappears in the "added" list when tracking resumes.

    Others in the threads I've linked report that the ARTrackedImage's tracking state never reports TrackingState.None.

    @tdmowrer can you weigh in on this? Will this bug be addressed?
  3. ibrahimpenekli


    Mar 10, 2015
    I think it is appeared in removed list if only if you manually remove the image anchor from the AR tracking pipeline. Maybe you should set timer when camera is facing image's last location and the tracking state is None. Remove image anchor manually when your elapsed time expired.
  4. arome90


    Jun 30, 2016
    Hi @ibrahimpenekli, I don't understand how do you recommend to do this. Could you post n example?
    Thank you so much