Bullet und health script

This commit is contained in:
2026-08-20 09:52:06 +02:00
parent c320f54ec9
commit cca8e87739
3 changed files with 40 additions and 5 deletions
+26
View File
@@ -0,0 +1,26 @@
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
public int maxHP = 100;
private int curHP;
void Start()
{
curHP = maxHP;
}
public void TakeDamage(int damageAmount)
{
curHP -= damageAmount;
if (curHP <= 0)
{
Die();
}
}
void Die()
{
Destroy(gameObject);
}
}