Hi!
In my game, I have a narrator. Oftentimes I want things to happen when the narrator finishes saying a line. Is there some sort of system in unity that lets me trigger events once the audio clip containing the narrator’s line finishes playing? Currently, the only thing I can think of is using a timer set to the length of the audio clip, but that could prove to be annoying if I ever change the dialogue.
Here’s some pseudo code / logic:
-
You could just get the Audio source clip length and store it, so no need to worry about length changing.
-
You could create a coroutine, that takes the length as input parameter.
-
Then make the coroutine wait until time matching the length of audio clip has passed.
-
Finally, trigger whatever you need. This could also be an Action or a delegate that is another parameter that your coroutine takes.