0

I'm a bit confused by this. I've got a particle system as a prefab, and I only want it to appear in the scene when a collision happens with the player. I also want it to appear in the same place as the player like the player has exploded. Here's what I have so far, forgive me if this is way off:

public class particleManager : MonoBehaviour {

    public ParticleSystem explosion;

    public bool emittingParticles = false; 

    public void Update () {
            if (emittingParticles == true) {
            explosion.enableEmission = true;
        }
    }
}

    void OnCollisionEnter2D (Collision2D col) {

            if (col.gameObject.tag == "enemyPlanet") {

                particles.emittingParticles = true; 

    } 
}

Am I on the right lines here? How do I instantiate the particle?

JGrn84
  • 750
  • 1
  • 9
  • 26
  • If you drag your prefab into the `explosion` field of this script, then you better `Instantiate()` it in the place you want it to be, or it won't be created. Just setting `emittingParticles` to `true` won't create the particle system. Other than that, the logic looks fine. – Maximilian Gerhardt Sep 25 '15 at 13:46
  • Thankyou instantiate() worked. – JGrn84 Sep 25 '15 at 18:19

0 Answers0