Shuriken - Don't destroy particles when emitter is destroyed

Is it somehow possible to keep the particles that have been already emitted when I destroy a particle system? I want to create an exhaust for a missile, but when the missile hits and is destroyed, the particle system, which is parented to the missile, is also destroyed and all particles die instantly instead of continuing their lifecycle…

3 Answers

3

They are part of it, so when it goes, they go. Can unchild it (to prevent the dead missile from sucking it into the grave,) stop spawning new ones and delay death long enough for them to all fade away:

Transform PE = transform.Find("exhaustPE");
PE.particleSystem.Stop();
PE.gameObject.parent = null;
Destroy(PE.gameObject, 5.0); // if particles live for at most 5 secs

Thanks. That seems to work. Wished there was an option to keep particles after destroying their parent system, though. Maybe for a later version of Unity (if one of the devs read this hinthint).

The particles aren't just fire-and-forget billboards with scripts. For speed, the particleSystem object purposely "owns" all the billboards, and organizes and draws them together. So "system dies, kids die" is baked in pretty thoroughly.

Some solutions to simpler cases:

  1. If you have a looping system that you want to fade:
    Set its loop property to false and its duration to 0.10.
  2. Alpha-fading:
    In some cases, you can fade a particle system by accessing its renderer.material component.
    Tween the alpha value of the color property to 0.

Don’t forget to unchild the particle system object (ej. psystem.transform.parent = null). If you disable or destroy the parent object, the system will go with it. You can destroy the p. system after its done fading.

One sort of workaround trick I used was that you can use a sub-emitter and parent it above the object that gets disabled. Then when that parent is destroyed it persists. I was stuck on this forever but it worked great for smoke trails after projectile hits and other things that would normally get cleaned up right away.