|
How i can detect if a sound have finished playing , so i can release the users actions?
(comments are locked)
|
|
If you use audio.Play(), you can check its completion with audio.isPlaying - it's true until the sound finishes. The example function below starts playing the sound and returns true; if called while the sound is playing, it returns false and does nothing: NOTE: Be aware that other alternatives like audio.PlayOneShot and AudioSource.PlayClipAtPoint don't affect isPlaying! When using those two functions, you can use a coroutine with a WaitForSeconds( clip.length )
May 06 '12 at 04:42 PM
Berenger
That's a good alternative that works for Play, PlayOneShot and PlayClipAtPoint. But remember that WaitForSeconds can only be used to pause coroutines - the coroutine that uses yield return new WaitForSeconds(time) will pause for the specified time. Coroutines run automatically in the background, thus the code that started the coroutine will not even notice the pause (StartCoroutine returns almost immediately - on the first yield, to be more precise).
May 06 '12 at 05:16 PM
aldonaletto
(comments are locked)
|
