Hello. I’m trying to play audio when the character dies. Here is what I have.
private var finish = false;
function OnControllerColliderHit(hit : ControllerColliderHit) {
if(hit.gameObject.tag == "KILL"){
finish = true;
}
if(finish){
Death();
}
}
function Death(){
Camera.main.SendMessage("fadeOut");
audio.Play();
LevelLoad();
}
function LevelLoad(){
yield WaitForSeconds(2);
Application.LoadLevel(1);
finish = false;
}
I’ve tried moving audio.Play()
to different parts of this code but it won’t work. Thanks in advance.