- Home /
Turn off Particle Emitter after few seconds?
How i turn off the Emitter after few seconds?
Answer by Alec-Slayden · Feb 17, 2011 at 12:31 PM
Here's a simple script you can put on the object with the particle emitter:
function Start(){
Invoke("StopEmitter", 3); //In 3 seconds, runs StopEmitter function
}
function StopEmitter(){
gameObject.GetComponent(ParticleEmitter).emit= false; //tell the emitter to stop.
}
You're welcome, however if you want this to turn off your emitter at a certain point ins$$anonymous$$d of a few seconds from start, you'll need to set it up differently
In any case the invoke expression should be a handy method.
Answer by $$anonymous$$ · Jul 20, 2019 at 11:34 PM
I used coroutine to achieve the wait behavior. But i don't is there any performance issue or its a bad approach for this secenario.
private ParticleSystem ps;
private void method1(){
StartCoroutine(nextLevelLoadTime());
}
IEnumerator startAndStopParticleSystem()
{
ps = GetComponentInChildren<ParticleSystem>();
ps.Play();
yield return new WaitForSeconds(3);
ps = GetComponentInChildren<ParticleSystem>();
ps.Stop();
yield return new WaitForSeconds(1);
callOtherFunction
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Script access to "Ellipsoid" property on Emitter 3 Answers
Is it possible to get specific subtypes of particle emitters' variables through scripts? 1 Answer
How to import the object from server to unity 2 Answers
resize particle emitter 1 Answer