Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Unity2D: Making a cloned particle system fire once only

$
0
0
I a have this enemy prefab that gets instantiated from a spawn point in my game, on the enemy prefab I have a particle system componet that if the player shoots the enemy more than 2 times the particle system will play. However I'm having problems with firing the particle system on only one of the enemy prefab that the player shot. Is there a way when the enemy prefab gets shot at to fire the particle system on that enemy prefab rather than the particle system playing when the enemy prefab gets shoot at and any other enemies prefabs that didn't get shot at without using ontriggerenter2d as I had some problems. This is the script attached to the player: public GameObject enemy; public static bool firePar = false; public static int combo = 0; void Start (){ firePar = false; combo = 0; } void OnTriggerEnter2D(Collider2D col) { if(col.tag == "Enemy") { Destroy(col.gameObject,0.2f); } } void Update() { if(combo >= 10) { firePar = true; } else if (combo < 10) { firePar = false; } } This is the code on the enemy (for firing the particles): private ParticleSystem par; void Start (){ par = GetComponent(); } void Update () { if(Playerbullet.firePar == true) { par.Play(); } else { par.Stop (); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>