- Home /
emit=false not working
I'm instantiating a little particle stream when a projectile hits an object. The stream is cloned (with emit off), positioned and rotated properly, turned on, set to destroy after 5 seconds and stop emitting after 1, but then fails to stop emitting. The code is the usual basic stop/start thing and I have tried using Autodestruct in place of Destroy but that makes no difference, the particle stream just will not stop. This requires a stream of particles so Emit() isn't an option and neither is One Shot. There are no errors anywhere.
Is there something in the 3 particle inspectors that could be locking it to emit once that's been set?
var quart = Quaternion.LookRotation(breach.normal);
abreach=Instantiate(GameObject.FindWithTag("hullbreach"),breach.point,quart);
Destroy(abreach,5);
abreach.transform.parent=collision.gameObject.transform;
abreach.GetComponent(ParticleEmitter).emit=true;
yield WaitForSeconds (1);
abreach.GetComponent(ParticleEmitter).emit = false;
Answer by Cap · Jun 05, 2010 at 04:20 AM
Okay, my mistake. The script that was handling the emitter spawning was on the projectile, which was destroyed after impact. The yield statement must have dropped the execution and then failed to pull it back up because the script no longer existed. I'll attach the kill statements to the emitter itself.
I'm leaving this here incase somebody else falls into the same trap (there really should be some kind of error in that situation). Mods, feel free to delete it if you want.
Your answer
Follow this Question
Related Questions
Particles do not appear on play but do on emit 0 Answers
Particle delay 1 Answer
Particle Thrust 1 Answer
Activating a particle emitter whith onTriggerEnter ? 5 Answers
Particle Sub Emitter Bug 5.5.3f1 0 Answers