How to create a Particle effect after a time limit

Hello! I’m currently testing a few levels for my project, and I needed to create an explosion after a short time limit. (For exemple: An explosion after 5 seconds)

I have my explosion particle set in place, but I just need a script to activate my explosion after a time limit.

If you guys have any kind of script that works or else a another answer that sounds familliar to this one, please post them below! :smiley:

Thanks!

~LittleL0L

Try this:

//js

function Start()
{
     particleEmitter.enabled = false; // turn the particle system off at startup
     yield WaitForSeconds (5); // wait for 5 seconds
     particleEmitter.enabled = false; // turn the particle system on
}

yield WaitForSeconds(); is probably the superior method for performance.

Another easy way to do it is just create an int variable timer. Set it to 0 on Start. Then do something like this:

int timer = 0;

Update()
{

if (timer > your desired number)
{

//put your particle effect/explosion stuff here
timer = 0;
your condition = false;
}

}


In FixedUpdate()
{

if (your condition)
{

++timer;
}
}

var lifeTime = 1.0;

function Awake ()

{
Destroy (gameObject, lifeTime);

}