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

How to make enemy explode after dying?

$
0
0
So far I have managed to make the enemy explode using a prefab however the enemy seems to explode constantly when I start the game rather than after dying. This is the enemy script: void Awake () { currentHealth = startingHealth; } public void TakeDamage (int amount) { currentHealth -= amount; healthSlider.value = currentHealth; if(currentHealth <= 0) { Destroy (gameObject); } } void OnTriggerEnter(Collider other) { if (other.tag == "Background") { return; } Instantiate (explosion, transform.position, transform.rotation); }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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