/// Inflicts damage, flash sprite, and check if the object should be destroyed public void Damage(int damageCount) { if (!active) { return; } hp -= damageCount; sr.material = matWhite; //Flash white // return from white flash after interval Invoke("ResetMaterial", flashInterval); if (hp <= 0) { // Dead! if (deathExplosion != null) { var deathExplosionTransform = Instantiate(deathExplosion) as Transform; deathExplosionTransform.position = transform.position; } dead = true; unitScript.Die(); } }