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;
//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);
}
}
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);
}