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…
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
Some solutions to simpler cases:
- If you have a looping system that you want to fade:
Set its loop property to false and its duration to 0.10. - 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.