Question by
KidGamingFTW · Apr 24, 2017 at 10:08 AM ·
collisionloadlevelbreak
Relaunching a scene messes up character
I have this script attached to an out of bounds barrier, when the character crosses it, he dies. When im taken to the main menu and i hit play from there after i die and go out of bounds again, the animation just repeats and it doesnt take me to the main menu.
#pragma strict
var Device : GameObject;
function OnTriggerEnter (col : Collider) {
if(col.gameObject.tag == "Player"){
col.GetComponent(Animation).Play("Death");
Device.SetActive(false);
wait();
}
}
function wait(){
gameObject.GetComponent(AudioSource).Play();
yield WaitForSeconds(2.3);
Device.SetActive(true);
SceneManager.LoadScene("MainMenu");
}
It onlyBreaks if i die then press play from the main menu, if i press play from the main menu without dying first, the script works, how do i fix it?
Comment