Sound Trigger Issue in Unity

That would be my first intuition.

Generally speaking…

if you have to use StopCoroutine(); then coroutines are not the correct solution.

If you want to persist with all of this start/stop coroutine stuff it will be harder to debug what’s going on, but at the end of the day you will still need to debug it to find what is happening before you can begin to fix it.

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Here’s more random coroutine reading.

Coroutines in a nutshell:

Splitting up larger tasks in coroutines:

Coroutines are NOT always an appropriate solution: know when to use them!

“Why not simply stop having so many coroutines ffs.” - orionsyndrome on Unity3D forums

Our very own Bunny83 has also provided a Coroutine Crash Course:

And another overview by Anders Malmgren:

3 Likes