if health <= 0:
$death.start()
$AnimatedSprite2D.play("death")
print(global.nborn_die)
if can_die == true:
self.queue_free()
I can't see your whole project, but it looks like you're deleting the death node before its animation finishes. That is typically solved by connecting the animation_finished signal to a function and moving the queue_free() there.
This may be as simple as deleting:
if can_die == true:
self.queue_free()
and replacing:
can_die = true
with:
set_physics_process(false)
queue_free()
Another problem is that $death.start() might be getting called repeatedly.
If the above call to set_physics_process(false) doesn't prevent that, you could add a boolean flag dying, which is initialized to false, and set to true in _on_death_timeout(). At the beginning of _physics_process(), check the flag, and return if it's true.