diff --git a/Assets/Scripts/ZombieController.cs b/Assets/Scripts/ZombieController.cs index d97973e..7f64daa 100644 --- a/Assets/Scripts/ZombieController.cs +++ b/Assets/Scripts/ZombieController.cs @@ -1,3 +1,4 @@ +using NUnit.Framework; using UnityEngine; [RequireComponent(typeof(Animator))] @@ -27,6 +28,8 @@ public class ZombieController : MonoBehaviour private Transform player; private Animator animator; + private bool IsDead() => currentHealth == 0; + private void Start() { currentHealth = maxHealth; @@ -36,7 +39,7 @@ public class ZombieController : MonoBehaviour private void Update() { - if (currentHealth == 0) return; + if (IsDead()) return; float distance = Vector3.Distance(transform.position, player.position); @@ -88,6 +91,8 @@ public class ZombieController : MonoBehaviour public void TakeDamage(float amount) { + if (IsDead()) return; + currentHealth -= amount; Debug.Log($"{gameObject.name} took {amount} damage. HP: {currentHealth}/{maxHealth}");