Hi, I made script that causes that object that have that script explodes after some damage. Problem is, that i have many of these objects in scene end when one object takes the damage, one other in scene explodes. I don’n know where i made a mistake. Thanks for help.
Here is the script:
var maxHealth : float; static var currentHealth : float; var dieSound : AudioClip; var dieVisual : GameObject; function Start() { currentHealth = maxHealth; } function Update() { if(currentHealth <= 0) { Destroy(); } } function Destroy() { AudioSource.PlayClipAtPoint(dieSound, transform.position); Instantiate(dieVisual, transform.position, transform.rotation); Destroy(gameObject); }