You've already forked zumbi-game
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
5d5b3c8e9a
|
|||
|
2c70174e69
|
|||
|
6bc9b5b15c
|
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
[RequireComponent(typeof(Animator))]
|
||||
|
||||
[RequireComponent(typeof(Animator))]
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class ZombieController : MonoBehaviour
|
||||
{
|
||||
@@ -31,17 +31,11 @@ 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()
|
||||
{
|
||||
if (player == null) return;
|
||||
if (currentHealth == 0) return;
|
||||
|
||||
float distance = Vector3.Distance(transform.position, player.position);
|
||||
@@ -87,7 +81,7 @@ public class ZombieController : MonoBehaviour
|
||||
if (Time.time - lastAttackTime >= attackCooldown)
|
||||
{
|
||||
lastAttackTime = Time.time;
|
||||
Debug.Log($"{gameObject.name} útočí na hráča za {attackDamage} damage!");
|
||||
Debug.Log($"{gameObject.name} attacked player by {attackDamage} damage");
|
||||
// player.GetComponent<PlayerHealth>()?.TakeDamage(attackDamage);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +89,7 @@ public class ZombieController : MonoBehaviour
|
||||
public void TakeDamage(float amount)
|
||||
{
|
||||
currentHealth -= amount;
|
||||
Debug.Log($"{gameObject.name} dostal {amount} damage. HP: {currentHealth}/{maxHealth}");
|
||||
Debug.Log($"{gameObject.name} took {amount} damage. HP: {currentHealth}/{maxHealth}");
|
||||
|
||||
if (currentHealth <= 0)
|
||||
Die();
|
||||
@@ -103,7 +97,7 @@ public class ZombieController : MonoBehaviour
|
||||
|
||||
private void Die()
|
||||
{
|
||||
Debug.Log($"{gameObject.name} je mŕtvy!");
|
||||
Debug.Log($"{gameObject.name} is dead");
|
||||
animator.SetTrigger(DieHash);
|
||||
Destroy(gameObject, 2f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user