How can i stop particle system after player get destroyed enter image description here


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) {

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

  • \$\begingroup\$ turn of looping and set Stop Action to Destory should do it. \$\endgroup\$ – edthethird Nov 17 '17 at 14:56
  • 4
    \$\begingroup\$ I would not bother using Update() for this. Simply calling Destroy(this, timeLeft); inside of Start() would be sufficient \$\endgroup\$ – Ed Marty Nov 17 '17 at 15:16
  • \$\begingroup\$ ok i finally solved it i disbale looping but there is another 3 child elements where looping was still enabled \$\endgroup\$ – Kartik Nov 17 '17 at 15:27
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – DMGregory Nov 17 '17 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.