- Home /
Playing a different audio clip after another has finished
Hello, I have a script that should play an audio clip after the default one is finished. I havent gotten any errors from unity and i got the script from the unity script reference. But when i try it in my game it doesnt play the second clip. Here is my script.
var otherClip: AudioClip; function Update () { audio.Play();
yield WaitForSeconds (audio.clip.length);
audio.clip = otherClip; audio.Play();
}
Thanks for any help!
Answer by Jesus_Freak · Nov 11, 2010 at 05:40 PM
var otherClip: AudioClip; var playNow = false;
yield WaitForSeconds (audio.clip.length); playNow = true;
function Update () {
if(playNow) { // Assign the other clip and play it audio.clip = otherClip; audio.Play(); playNow = false; }
}
Your answer
Follow this Question
Related Questions
audio.clip.length 'hides' my button! yaiks! 1 Answer
Can't select audio clip even though it's there 1 Answer
Get length from state in Animator 1 Answer
Playing Sound 2 Answers
Script not working anymore 1 Answer