- Home /
shuriken auto destruct script doesn't ALWAYS work?
Hi, after looking around on the net i found this code :
function LateUpdate () { if (!particleSystem.IsAlive()){ Destroy (this.gameObject);
} }
to destroy particle systems instantiated ingame, the majority of the time the code does as it should, but every odd runtime, (even if i haven't changed the scene in any way), it will still show the 6 white circles when the particle system ends, is there a more solid code?
Does the particle system still appear in the hierarchy? Have you tried attaching the particle system to an empty game obj?
well when the autodestruct doesn't work it still shows up in the hierarchy for a little longer, as if there is a delay on the autodestruct, but there is nothing telling it to delay, and its completely random whether or not it autodestructs on time or waits a few seconds.
Have you tried setting it as inactive after destroying it? The object will definitely live on until at least the end of the frame.
Yes; directly after it and recursively. It might help. Not 100% sure, though...
Answer by ratboy · Apr 19, 2012 at 10:28 PM
Really silly - crossing over assets from a PC to a mac, and the Unity Explosion Framework doesn't support IOS, lesson - always read the small print.
Answer by IndieForger · Feb 17, 2013 at 04:24 AM
Consider moving LateUpdate check to external controller. You might gain a little performance. I wrote full explanation in article: Auto destroying particle system in unity3d