You've already forked zumbi-game
simplify player transfor getter in zombie controller
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
[RequireComponent(typeof(Animator))]
|
|
||||||
|
|
||||||
|
[RequireComponent(typeof(Animator))]
|
||||||
[RequireComponent(typeof(Rigidbody))]
|
[RequireComponent(typeof(Rigidbody))]
|
||||||
public class ZombieController : MonoBehaviour
|
public class ZombieController : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -31,12 +31,7 @@ public class ZombieController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
currentHealth = maxHealth;
|
currentHealth = maxHealth;
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
|
player = GameObject.FindGameObjectWithTag("Player").transform;
|
||||||
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
|
|
||||||
if (playerObject != null)
|
|
||||||
player = playerObject.transform;
|
|
||||||
else
|
|
||||||
Debug.LogWarning("Zombie nenašiel hráča — skontroluj tag 'Player'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|||||||
Reference in New Issue
Block a user