How i can detect if a sound have finished playing , so i can release the users actions?
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:
bool PlayClip(AudioClip sound){
if (audio.isPlaying) return false;
audio.clip = sound;
audio.Play();
return true;
}
NOTE: Be aware that other alternatives like audio.PlayOneShot and AudioSource.PlayClipAtPoint don’t affect isPlaying!