- Home /
Autodestruct multi-particle system
I would like to create an effect with multiple particle systems. So I grouped them into an empty object. Now there is a problem because the particle systems autodestruct but the empty object gets left behind. How do I make it autodestruct when all the contained particle systems are destroyed?
Answer by femi · Dec 27, 2010 at 01:28 PM
how about attaching to the parent something like:
function LateUpdate () {
if (transform.childCount == 0)
Destroy(gameObject);
}
?
Answer by IndieForger · Feb 17, 2013 at 04:24 AM
Oh that entirely depends on the scenario you are running. Using update might be better in some cases in others using coroutine.
You shouldn't use childCount
method. IsAlive()
would be better for cases where you have particle bursts every some time.
I wrote a post Auto destroying particle system in unity3d about observations I made during the research.