Files
No-Time-To-Rest/Assets/Scripts/Player/Player.cs
T
KOSMOGOR dc6707f2a9 add: Player script with hp
add: player death handling and OnLevelFailed event
2025-04-25 13:40:23 +03:00

20 lines
340 B
C#

using UnityEngine;
public class Player : MonoBehaviour
{
public float maxHp = 100;
[SerializeField] float hp;
void Start() {
hp = maxHp;
}
public void DealDamage(float damage) {
hp -= damage;
if (hp <= 0) {
FindAnyObjectByType<LevelController>().OnPlayerDie();
}
}
}