Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Help Wanted Image Tracker: Setting GameObject false when tracking is lost.

Discussion in 'Unity MARS' started by Sisanda, Jun 4, 2021.

  1. Sisanda

    Sisanda

    Joined:
    Oct 3, 2017
    Posts:
    10
    Hi Guys,

    I recently got Unity Mars and I was trying to build an image tracking app, it works but my only problem is when the target image is lost the GameObject remains active. I tried changing the ShowChildrenOnTrackingAction script:

    From:
    switch (newState)
    {
    case QueryState.Acquiring:
    for each (Transform child in transform)
    {
    objectsToActivate.Add(child.gameObject);
    }

    break;
    case QueryState.Resuming:
    case QueryState.Unavailable:
    case QueryState.Unknown:
    foreach (Transform child in transform)
    {
    objectsToDeactivate.Add(child.gameObject);
    }

    break;
    }

    To:
    switch (newState)
    {
    case QueryState.Acquiring:
    for each (Transform child in transform)
    {
    objectsToActivate.Add(child.gameObject);
    }

    break;
    case QueryState.Resuming:
    case QueryState.Unavailable:
    foreach (Transform child in transform)
    {
    objectsToDeactivate.Add(child.gameObject);
    }

    break;

    case QueryState.Unknown:
    foreach (Transform child in transform)
    {
    objectsToDeactivate.Add(child.gameObject);
    }

    break;
    }

    But when I save it, the script reverts back to the initial script. My question is how can I deactivate the object when the image target is lost.
     
  2. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    258
    hello @Sisanda

    Just add a
    TrackingStateCondition
    and set it to "Tracking" to be able to remove the gameobjects when lost.

    The minimum tracking state field in the
    TrackingStateCondition

    refers to the minimum quality of object tracking needed to maintain this Proxy's match.
    Depending on what is set it means different things:
    Unknown: No tracking
    Tracking: Tracking is working normally
    Limited: Some tracking information is available, but it is limited or of poor quality

    Note that the meaning of "limited" differs a bit between platforms; on iOS markers always have a state of "tracking" while they are visible, however on Android they will sometimes drop to "limited" if the visibility is poor, e.g. if there's motion blur.
     
  3. Sisanda

    Sisanda

    Joined:
    Oct 3, 2017
    Posts:
    10
    Hi @jmunozarUTech,

    Thank you so much it works perfectly. is any full course on Unity Mars that you can recommend for me?
     
  4. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    258
    hello @Sisanda, Unfortunately there is not MARS Course I can recommend, we do have some webinars https://create.unity3d.com/Getting-started-with-MARS

    And the docs landing page (https://docs.unity3d.com/Packages/com.unity.mars@1.3/manual/index.html) which depending on where you want to start you can select any of the links.

    Hope this helps :)
     
  5. Sisanda

    Sisanda

    Joined:
    Oct 3, 2017
    Posts:
    10
    Thank you, it did help
     
    jmunozarUTech likes this.
unityunity