15 lines
217 B
GDScript
15 lines
217 B
GDScript
class_name HealthComponent
|
|
extends Node
|
|
|
|
@export var max_health: float
|
|
var health: float
|
|
|
|
func _ready():
|
|
pass
|
|
|
|
func take_damage(attack: Attack):
|
|
health -= attack.damage
|
|
|
|
if health <= 0:
|
|
get_parent().queue_free()
|