Log in or register to post comments

Event Tracking Status Problems

February 20, 2020 - 11:23pm #1

Hello,

I am triggering events via Tracking of an Image Target with the following code:

 

public class NewTrackingCanvas3 : MonoBehaviour, ITrackableEventHandler

{

    private TrackableBehaviour mTrackableBehaviour;

    public AudioSourceTracking audiosourcetracking;

    void Start()

    {

        mTrackableBehaviour = GetComponent<TrackableBehaviour>();

        if (mTrackableBehaviour)

        {

            mTrackableBehaviour.RegisterTrackableEventHandler(this);

        }

    }

    public void OnTrackableStateChanged(

                                    TrackableBehaviour.Status previousStatus,

                                    TrackableBehaviour.Status newStatus)

    {

        if (//newStatus == TrackableBehaviour.Status.DETECTED)// ||

            newStatus == TrackableBehaviour.Status.TRACKED) //||

                                                            //newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

        {

            // Play audio when target is found

            audiosourcetracking.StartSound();

        }

        else

        {

            // Stop audio when target is lost

        }

    }

}

 

 

So the audio shall be played when the status is changed to normal. I have different images with different functions on tracking.

Sometimes after some time showing the image, the status is changed back from unknown to normal, although the image is not shown anymore. So the function is called randomly. I also tried implementing it via the OnTrackingFound() function, with the same result.

I am using Unity 2019.2.12f1 and and Vuforia 8.5.9. 

Do you have any idea what the reason could be for this behaviour? How can I stop it to change back from unknown to normal without image.

Thank you!

 

Log in or register to post comments