19 lines
293 B
GDScript3
Raw Normal View History

2024-02-12 23:22:27 +00:00
class_name HealthComponent
extends Node
signal value_changed
@export var max_value: float
var value: float
func _ready():
value = max_value
value_changed.emit()
func take_damage(attack: DamageInstance):
value -= attack.damage
value_changed.emit()
if value <= 0:
owner.queue_free()