Bullet und health script
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user