"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Make the object dissapear when not detected

I've been trying to edit a script i found that plays a sound when the target is found (and it works) , but i can't manage to do the following: make the object above the target dissapear when not detected ( so it doesn't stay on the screen after it's lost) 

 

using UnityEngine; using System.Collections; using Vuforia;

public class SunetSucces : MonoBehaviour, ITrackableEventHandler { private TrackableBehaviour mTrackableBehaviour;

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    GetComponent<GameObject>().SetActive(true);   }   else   {    // Stop audio when target is lost    GetComponent<GameObject>().SetActive(false);   } }   }

 

And it doesn't work, so any ideas why? or do you have any other script like this? i'd rly apriciate it 

Hello 4I3x21,

Having an object disappear when the image target isn't detected is done in the Vuforia sample project. I'd recommend downloading it from the Unity App Store and checking it out.

Thank you :) i will 

I looked it up and i need to upgrade unity...i can't do that, the last time i tried it , it really messed up ALL the contect of my project....

If you need to update Unity purely for the sample project, you could download the newest version and install it in a separate location from the version you use for your main project.

Hi 4l3x21,

I'm not sure whether you tried this, but did you disable the Extended Tracking?

it's not turned on. the problem with my app is , if the target is lost or you move the camera too fast, the object frezes on the screen