Files
CastleDefence/Assets/Scripts/EnemyHealthController.cs

24 lines
490 B
C#
Raw Normal View History

2026-04-02 16:20:38 +01:00
using UnityEngine;
public class EnemyHealthController : MonoBehaviour
{
[SerializeField] float totalHealth;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void TakeDamage(float damageToTake)
{
totalHealth -= damageToTake;
if(totalHealth <= 0)
Destroy(gameObject);
}
}