List
Detect which image target
Posted Date: 2017-11-20 4:44     Edited Date: 2019-11-07 23:28     Writer: inactive

Hello, I want to ask whether there is a way to play a sound when a specific image target is detected.

I found that inside ImageTrackerSample has a code that debug the name of image target;

    imageTrackablesMap.Add(trackable.TrackableName, trackable);

 

So I was wondering if I can use if statement to specify which image target currently detected.

Thank you.

 

Posted Date: 2017-11-20 7:58     Edited Date: 2017-11-20 7:58     Writer: inactive

A target image can work as a trigger not only to call up 3D models but also to play music. Actually, it can be a trigger for whatever you want. It's up to your code.

Yes, you can specify which image the detected one is.  

Posted Date: 2017-11-21 1:33     Edited Date: 2017-11-21 1:33     Writer: inactive

Ok, I understand that. But I tried to make the code like this;

    foreach (var trackable in imageTrackables)
        {
            imageTrackablesMap.Add(trackable.TrackableName, trackable);
            if (trackable.TrackableName  == "manual") 
            {
                //playSound("sounds/03 Heartless");
                cube.SetActive(true);
                soundTarget.Play();
                Debug.Log("Hello");
            }

I put it in ImageTrackerSample but it is not working. Only the active/deactive 3d object is working. Am I misplacing the code?

Posted Date: 2017-11-21 4:13     Edited Date: 2017-11-21 4:24     Writer: inactive

Hi,

Maybe unity AudioSource.Play should be called only once.

So, please try the code snippet like below.

if (soundTarget.isPlaying != true)

{

   soundTarget.Play();

}

Thanks for using our sdk :-)

Posted Date: 2019-11-07 23:10     Edited Date: 2019-11-07 23:28     Writer: inactive

How can we know which target is detected? We need a way to find out wich specific target is detected to play an specific audio just one time when that target is detected and stop it one time when the target is lost.

 

Thank You,

Javier.