Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Why this ParticleSystem is being destroyed when I uncheck "Play On Awake"?

miguel8822miguel8822 Member
edited May 2020 in Programming

Hello Community!

I am new to video game development, Im currently working on my first project which I started a couple months ago.

Im trying play a smoke Particle System on a chopper prefab once that chopper's hp falls below 50% of its maximum hp. I've been looking on google for several hours without find any solution. I know there are other ways to achieve this but I would really want to know what is destroying the Particle System. Strangely, the Particle System dont gets destroyed if I check the Play On Awake tick on the smoke particle system. Otherwise, it gets destroyed after 0.6 secs. Here is the code which I guess are the important lines, (language used is C#),


          private void OnCollisionEnter2D(Collision2D collision)


       if (collision.gameObject.CompareTag(bulletType[0]) || collision.gameObject.CompareTag(bulletType[1]))



           Invoke("WaitFewSecondsToPlayAlertVoice", 0.5f);


           TakeDamage(Random.Range(30, 41));          



 private void ActivateSmokeBasedOnCurrentHP()


       if (GameManager.instance.globalHelicopterCurrentHealth < 0.50f * GameManager.instance.globalHelicopterMaxHealth)


           greySmokeParticleSystem.Play(); //At this line error in console pops up.


       else if(GameManager.instance.globalHelicopterCurrentHealth <= 0.25f * GameManager.instance.globalHelicopterMaxHealth)






Error message in console:

MissingReferenceException: The object of type 'ParticleSystem' has been destroyed but you are still trying to access it.

Your script should either check if it is null or you should not destroy the object.

UnityEngine.ParticleSystem.Play () (at <7137a609105f472a9773b5a9b6df383f>:0)

Helicopter.ActivateSmokeBasedOnCurrentHP () (at Assets/Scripts/Helicopter.cs:88)

Helicopter.OnCollisionEnter2D (UnityEngine.Collision2D collision) (at Assets/Scripts/Helicopter.cs:57)

Apologies for my bad English. Hope is good enough to express my point. Wasnt sure how many lines of code should I've been posted since guidelines says I should post the important stuff, let me know if you need the entire script. Thank you in advance.


  • miguel8822miguel8822 Member
    edited May 2020

    I gave up trying to find an answer to my question. I copied and pasted in google the error shown in console and found some people saying that this error is related to unity editor.

    In order to activate the smoke particlesystem, I checked Play On Awake on the original smoke particlesystem prefab and used the "conventional" method to play it.

  • WarpWarp Administrator

    A picture of your particle system component would be helpful aswell.

  • This morning, I replaced the smoke ParticleSystem with a blood particle system which I use on Player and Enemies and doesnt cause any issues (I know that a chopper bleeding is weird, I did it just to see if the error trigger in console when I place this bloodParticleSystem). No errors occurried with blood ParticleSystem which makes me think that something is messed up with the smokeParticleSystem. Please give me a few minutes, my pc is really slow and takes several minutes just to open the unity editor.

  • miguel8822miguel8822 Member
    edited May 2020

    The bloodParticleSystem works perfectly while smokeParticleSystem causes the error.

Sign In or Register to comment.