I’ve been having some issues when playing a particlesystem when my gameobjects dies. This is the code that I run when my gameobject dies:
public IEnumerator destroyStuff(){
myExplosion = (ParticleSystem) GameObject.Instantiate((Object)explosion);
myExplosion.transform.position = transform.position;
myExplosion.Play();
Destroy (gameObject);
Destroy (redPartHealthBar);
Destroy (greenPartHealthBar);
Destroy (blackPartHealthBar);
Destroy (triggerArea);
yield return new WaitForSeconds(myExplosion.duration);
Destroy (myExplosion.particleSystem);
}
This is what comes up after the particles are done playing and they are destroyed : Imgur: The magic of the Internet
The wait duration was to try and destroy the particle system as fast as I can after it’s done playing, so this things I circled in the image above don’t pop up.
Thanks in advance for helping me out.