Detect which image target
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.
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.
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?
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 :-)
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.