After the player dies, I want to go to the next scene, but i want the explosion to finish first. The object is destory with the explosion but after that nothing happens?
function OnTriggerEnter (other : Collider) {
//Check for the block
if(other.gameObject.tag == "block")
{
print("Boom");
//Create explosion
Instantiate(explosion, transform.position, transform.rotation);
//Destory player
Destroy(gameObject);
yield WaitForSeconds (2);
Application.LoadLevel (2);
}
}
Maybe hiding the player will work. GameObjects get destroyed on LoadLevel unless instructed not to.
function OnTriggerEnter (other : Collider) {
//Check for the block
if(other.gameObject.tag == "block")
{
print("Boom");
//Create explosion
Instantiate(explosion, transform.position, transform.rotation);
//Destory player
gameObject.SetActiveRecursively(false); // Replaced Destroy(gameObject);
yield WaitForSeconds (2);
Application.LoadLevel (2);
}
}
I’m gonna answer my own question, if anybody else get this problem. When the gameObject is destoyed, so is the yield and application. I just but this code on the block instead.
function OnTriggerEnter (other : Collider) {
//Check for the block
if(other.gameObject.tag == "Player"){
yield WaitForSeconds (3);
Application.LoadLevel (3);
}
}