- Home /
How To destroy a particle system in Unity 3.5
I have updated my Unity to 3.5, and unfortunately I never got used to the new Particle System, that I can't find the "Auto Destruction" option...
can anyone tell me how to destroy a particle when it finished playing? Thanks!
Answer by Karsten · Apr 23, 2012 at 12:00 AM
Add a script to the Particlesystem and in that script alter the Update function so that it looks like this
function Update () { if (!particleSystem.IsAlive()) Destroy (gameObject); }
I would vote this up, but I'm not allowed - thanks for the answer!
Answer by yusufulutas · Apr 20, 2012 at 08:55 AM
Unfortunately new particle system don't have auto destruction but if you close looping,your particle becomes disable. maybe this can help you.
Thanks, still I wanna ask is, is there any way I can detect whether the particle has finished and destroy it on script?
This solution isn't effective because when closing the looping feature making the particle system invisible, will this cause the system taking up resources? I don't know how Unity3d engine handle this? Will the engine auto dispose just like JV$$anonymous$$?
Answer by citizen_rafiq · Oct 27, 2012 at 12:27 AM
if you want to destroy previous example is enough but if you want to reuse it again and again without creating clone object then you don't need to Instantiate or destroy it just play it, where and when you want :)
1.unchecked looping from particle system editor 2.create a transform variable in your script as public(example explosionTrans)and set your particle object from editor. 3.now in your update method
explosionTrans.particleSystem.transform.position=this.transform.position; explosionTrans.particleSystem.Play();
particle object will follow your game object position which is assign by you this script
For some reason this doesn't work as intended. If I try to create 3 explosions at once, some of the explosions just won't show up randomly. Sometimes it creates all 3, sometimes just 2, sometimes none. They're either created at the same position and I can't spot that, or they're not created at all.
Recently i am using different way to make group particle explosion.1.I create a empty game object and make it as parent of all explosion that I wanted to be grouped named root_exp_grenade. 2.when a grenade droped on the ground I take the landing position and Instantiate root_exp_grenade and boom (GameObject go = Instantiate(root_exp_grenade,transform.position, Quaternion.Euler(Vector3.zero)) as GameObject; ) 3.there is script attached with root_exp_grenade and it destroy the object after a fixed time, you can load root_exp_grenade form resource or set it from Assets in a public var. You can also Instantiate a fixed number of root_exp_grenade first and pooling them and active them using SetActiveRecursively(true) and inactive them using SetActiveRecursively(false).
you can destroy it with Destroy(gameObject , sometime); this sometime can be any integer depending on after how many seconds you want to destroy the particle system.
Answer by huahsin68 · Aug 27, 2013 at 12:40 PM
I have come across the similar problem before, this is how I solved it. In particle system you have created, check whether you have Particle Animator
component install into the particle system, if not it is accessible through Component
> Effects
> Legacy Particles
, you should see the autodestruct option rigth inside this component.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070536im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Water emission using c# 1 Answer
Problem with changing color of particles 3 Answers
particleSystem.Play(); wont start 1 Answer
Particle system not moving 0 Answers