Files
GoblinRaid/Assets/Scripts/Core/Health.cs
Caleb Sandford deQuincey e2b97323a3 Started building first moment
2025-10-31 20:33:41 +00:00

34 lines
704 B
C#

using Unity.VisualScripting;
using UnityEngine;
namespace RPG.Core
{
public class Health : MonoBehaviour
{
[SerializeField] float health = 100f;
bool isDead = false;
public bool IsDead()
{
return isDead;
}
public void TakeDamage(float damage)
{
health = Mathf.Max(health - damage, 0);
if (health == 0)
{
Die();
}
}
private void Die()
{
if (isDead) return;
isDead = true;
GetComponent<Animator>().SetTrigger("die");
GetComponent<ActionScheduler>().CancelCurrentAction();
}
}
}