Hi guys , how can i clear up any left over particles on screen , after disabling the emitter?
Basicly, i have an emitter which i turn on and off … but after turning it off … particles are still left in the last spot it was located…
Hi guys , how can i clear up any left over particles on screen , after disabling the emitter?
Basicly, i have an emitter which i turn on and off … but after turning it off … particles are still left in the last spot it was located…
Ahh theres my mistake.
ParticleEmitter.eneabled = false Doesnt work.
ParticleRenderer.enabled = false … seems to work fine if anyone else needs to know.
I usually disable the emitter using particleEmitter.emit = false, then any remaining particles die off naturally and the autodestruct cleans up the emitter afterwards.
Ah hah , even better , yea that definately works better than my slouch method , thanks.
profanicus, Is there any way to determine if any of those particles are still on the screen? I have an emitter used as a “gun” that shoots sparks, I’m playing a sound effect as a keypress fires and emits the sparks. I’m achieving this as you say by disabling the emitter to have one puff of sparks per keypress, but if the user button mashes the sound effect will play even though no sparks are created.
How can I check (between the time the user KeyUpped and the sparks are dying off naturally from the emitter being set to false) that there are any particles left on screen? I want to only allow you to fire again only after all particles have died.
thanks
psdev, you shouldn’t need to disable/enable any emitters for something like that, just can just use the “one shot” function in the emitter and instantiate particles on every keypress.
Since you likely know the lifespan of your particles, you could just fake it by using a timer that stops the player pressing the key again until this time is up.
Or even easier, assign the particle instantiation to a variable, and only allow the player to fire if this variable is null (it will become null when all the particles die).
If you do decide to keep a single emitter and enable/disable emission, another way might be to check particleCount on your emitter when the key is pressed, and if it’s greater than zero then don’t fire.
Thanks profanicus!
I was doing a one shot and had to set emit = true on the KeyDown and emit = false on the KeyUp, but because of the way I was playing the sounds and animating light intensities with iTween, I needed a way to check for particles still alive before allowing a second shot.
Your idea of checking the emitter.particles.Length >0 was perfect. Appreciate the tips!