1
0
Fork 0
1bit-godot-course/metroidvania/Scenes/Enemies/EnemyStats.gd

14 lines
277 B
GDScript

extends Node
signal enemy_died
export (int) var max_health = 1
# Needs to be onready to use the max_health variable
onready var health = max_health setget set_health
func set_health(value):
health = clamp(value, 0, max_health)
if health == 0:
emit_signal("enemy_died")