# How to destroy particles system after its work is over

How can i stop particle system after player get destroyed

First of all, your particle system appears to have looping enabled. You usually don't want that for an explosion effect. When that's not the case, then there is likely something wrong with one of the scripts which control that explosion effect or your particle effect uses a sub-emitter which loops.

In Unity Version 2017.2, the particle system got a new parameter Stop Action on the "Main" module. The default value is "None". When you set it to "Destroy", the game object with the particle system will be destroyed as soon as there are no alive particles anymore. But this, of course, won't do much when you still have "Looping" enabled.

When you don't want to update to 2017.2, you can add a "self-destruct" script to the game object with the particle effect which destroys it after a specific time elapsed:

public class SelfDestruct : MonoBehaviour {
public float timeLeft;

void Update() {
timeLeft -= Time.deltaTime;
if (timeLeft <= 0.0f) {
Destroy(this.gameObject)
}
}
}


Set "Time Left" in the inspector to the number of seconds you want the object to exist.

• turn of looping and set Stop Action to Destory should do it. – edthethird Nov 17 '17 at 14:56
• I would not bother using Update() for this. Simply calling Destroy(this, timeLeft); inside of Start() would be sufficient – Ed Marty Nov 17 '17 at 15:16
• ok i finally solved it i disbale looping but there is another 3 child elements where looping was still enabled – Kartik Nov 17 '17 at 15:27
• You can also check ParticleSystem.IsAlive() instead of requiring the user to specify the time in a variable (and update it any time they tweak the particle animation...). This returns true as long as the particle system still running or has any particles active, and false once it's safe to clean it up. – DMGregory Nov 17 '17 at 18:38