Play sound when targets get detected

0 votes
asked Feb 25 by waihan95 (170 points)
Hi! I am new to Easy AR and I want to ask how to add code in the image target to trigger sound when targets get detected?

I am using EasyAR 4.0 SDK. Thank you!

1 Answer

0 votes
answered 4 days ago by migferhed (240 points)
In ImageTargetController.cs add:

 public AudioClip sonido;
 AudioSource reproductor;

...

 protected override void Start()
        {
            if (reproductor == null) reproductor = gameObject.AddComponent<AudioSource>();

.....

       }

....

 protected override void Start()
        {

           reproductor.clip = sonido;
            reproductor.Play();

        }
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...