cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Translate the entire conversation x

TrackableBehaviour / ObserverBehaviour could not be found

EZ_12871053
3-Newcomer

TrackableBehaviour / ObserverBehaviour could not be found

Vuforia can track my target image, but I'd like to add a component (new C# script) to the Image target object, such that it waits 3 seconds upon finding the image, and then randomly places one of the 3d (child) objects

 

Unfortunately, the console shows the error TrackableBehaviour / ObserverBehaviour could not be found.  How can this be done in Unity6?

 

Delay.cs

 

 

using UnityEngine;
using Vuforia;

public class Delay : MonoBehaviour, ITrackableEventHandler
{
    private TrackableBehaviour mTrackableBehaviour;
    public GameObject childObject;

    void Start()
    {
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.OnTargetStatusChanged += OnTrackableStateChanged;
        }
    }

    public void OnTrackableStateChanged(StatusChangeResult statusChangeResult)
    {
        if (statusChangeResult.NewStatus == Status.TRACKED)
        {
            StartCoroutine(PlaceObjectAfterDelay());
        }
    }

    IEnumerator PlaceObjectAfterDelay()
    {
        yield return new WaitForSeconds(3);
        Vector3 randomPosition = new Vector3(Random.Range(-0.5f, 0.5f), 0, Random.Range(-0.5f, 0.5f));
        childObject.transform.localPosition = randomPosition;
    }
}

 

 

1 REPLY 1

Hi @EZ_12871053,

your question seems to be a question related  to Vuforia Engine & Unity   and is not directly related to the Vuforia Studio community and  to the  Vuforia Studio product.  Therefore I want to refer to the Vuforia Development portal/ support -  https://developer.vuforia.com/support where issues related to Vuforia Engine /also usage in  unity enviroment / are reported /documented

You have the option to  ask questions and discuss issues with other Vuforia Engine and Unity developers via the official vuforia tag on Stack Overflow

 on https://stackoverflow.com/questions/tagged/vuforia

BR

Announcements
Top Tags