Log in or register to post comments

Make the object dissapear when not detected

June 17, 2017 - 5:04am #1

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 

Make the object dissapear when not detected

June 20, 2017 - 6:11pm #6

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

Make the object dissapear when not detected

June 20, 2017 - 3:30am #5

Hi 4l3x21,

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

Make the object dissapear when not detected

June 19, 2017 - 9:48am #4

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. This way you can open the sample in the newest version and have a reference for the various features while maintaining the version of Unity you have for your project. Just keep in mind that since you're on an older version of Unity, the sample might not be a perfect 1 to 1 reference for you.

 

Make the object dissapear when not detected

June 19, 2017 - 9:40am #3

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....

Make the object dissapear when not detected

June 19, 2017 - 9:00am #2

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.

Thanks.

Log in or register to post comments