public void Hit(float damage, Transform attacker = null) { currentHealth -= damage; healthImage.fillAmount = currentHealth / MaxHealth; if (controller != null) { controller.HitByEnemy(attacker); } unitsManager.UnitsInRange(transform.position, attacker); healthImage.color = (healthImage.fillAmount < 0.2) ? Color.red : Color.green; if (currentHealth <= 0) { Die(); } }