Improved respawn

This commit is contained in:
2024-02-13 13:49:28 +01:00
parent bbef2a0a4a
commit 4c1d8ab877
7 changed files with 75 additions and 25 deletions

View File

@ -8,14 +8,23 @@ const DEATH_THRESHOLD = 0.01
@export var max_value: float
var value: float
var is_dead: bool
func _ready():
restore()
func restore():
is_dead = false
value = max_value
value_changed.emit()
func take_damage(attack: DamageInstance):
if is_dead:
return
value = clampf(value - attack.damage, 0, max_value)
value_changed.emit()
if value < DEATH_THRESHOLD:
is_dead = true
death.emit()