add zombie controller and implement damage system; update gun controller for raycasting; modify prefab and scene settings

This commit is contained in:
dkecskes
2026-05-04 12:39:20 +02:00
parent 957f8845b9
commit 835127238a
8 changed files with 117 additions and 6 deletions
+29
View File
@@ -0,0 +1,29 @@
using UnityEngine;
public class ZombieController : MonoBehaviour
{
[SerializeField] private float maxHealth = 100f;
private float currentHealth;
private void Start()
{
currentHealth = maxHealth;
}
public void TakeDamage(float amount)
{
currentHealth -= amount;
Debug.Log($"{gameObject.name} dostal {amount} damage. HP: {currentHealth}/{maxHealth}");
if (currentHealth <= 0)
{
Die();
}
}
private void Die()
{
Debug.Log($"{gameObject.name} je mŕtvy!");
Destroy(gameObject);
}
}