simplify player transfor getter in zombie controller

This commit is contained in:
2026-05-05 11:11:07 +02:00
parent 0c622deb68
commit 6bc9b5b15c
+2 -7
View File
@@ -1,6 +1,6 @@
using UnityEngine;
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Rigidbody))]
public class ZombieController : MonoBehaviour
{
@@ -31,12 +31,7 @@ public class ZombieController : MonoBehaviour
{
currentHealth = maxHealth;
animator = GetComponent<Animator>();
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
if (playerObject != null)
player = playerObject.transform;
else
Debug.LogWarning("Zombie nenašiel hráča — skontroluj tag 'Player'");
player = GameObject.FindGameObjectWithTag("Player").transform;
}
private void Update()