It looks like you're new here. If you want to get involved, click one of these buttons!
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) || collision.gameObject.CompareTag(bulletType))
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.