restart level after time

Hello, I’m just starting out with scripting (javascript). I made this character when it collides with an object apart from the explosion. I wanted to make that 5 seconds after collision ripartisse the scene. This is my code. The collision works but does not start the game.

# pragma strict



var fire: ParticleEmitter;



function Start () {





 yield WaitForSeconds (5);

Application.LoadLevel (0);



}





OnTriggerEnter function (other: Collider) {


 Destroy (gameObject);

Destroy (other.gameObject);


 fuoco.emit = true;





 Start ();







 }
# pragma strict
     
var fire: ParticleEmitter;

//do not use yield in function start, update, fixedupdate, etc    
//instead of loading level "0", reload current "loadedLevel"
//also going to make this a custom function

//haha, yes, this function was incorrectly formatted
function OnTriggerEnter (other: Collider) {
Destroy (other.gameObject);
fuoco.emit = true;
Example ();
}

function Example(){
yield WaitForSeconds(5);
Application.LoadLevel(Application.loadedLevel);
}

or

var reloadTime : float;

function Example () {
if (reloadTime < 5) {
reloadTime = Time.time; //or Time.deltaTime
}

else {
Application.LoadLevel(Application.loadedLevel);
}

}

both do not work

is the code that relates to the time wrong. If I remove the level restarts immediately without seeing the whole animation of the explosion

“function OnTriggerEnter”, not “OnTriggerEnter function”

“does not work” is not at all helpful. If that’s all the information you give us we’ll never be able to help.

What exactly do you want to happen, what exactly is happening? Are there errors? What lines are the errors on?

I had used before “function OnTrigger enter” not “On Enter trigger function”, however, I gave the script to bomb. This is the code, however, does not work time. You do not restart after 5 seconds

# pragma strict

     

var fuoco: ParticleEmitter;

 



 

Function OnTriggerEnter (other: Collider) {

Destroy (other.gameObject);

fuoco.emit = true;

Example ();

}

 

function Example(){

yield WaitForSeconds(5);

Application.LoadLevel(Application.loadedLevel);

}

I think you need to “StartCoroutine(Example())”.

now it works thank you very much: D