15 lines
217 B
GDScript3
15 lines
217 B
GDScript3
|
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()
|