no it repeats the animation over and over. even though i started the timer. in the timeout function i mentioned queue_free().
That’s easy. _process function is called every frame so If you reach health==0 your boss dies over and over. The easiest solution is making new variable alive, set it to true by default and then alter your _process function like:
var alive = true
func _process(delta):
if health <= 0 and alive:
# Here goes your die code
$death_timer.start()
$AnimationPlayer.play("death")
alive = false
Now die code triggers only once. Let me know if it works.
Or you can do it in more elegant fashion by using setter function on health variable.
var health = 100 setget set_health
...
func set_health(value):
health = value
if value <= 0:
die()
...
func on_area_entered(area):
self.health -= 5. # It's very important to write self.health instead of health if you use setter function
...
func die():
$death_timer.start()
$AnimationPlayer.play("death")