I'm making a player's death system, but when the enemy collide with the player, nothing happens, well... it print in log how many life's left but its just it, i have created the area 2D group (Hurtbox) and (power(The enemy's area group)), colissionshape and everything else
Asked
Active
Viewed 190 times
1 Answers
1
Play the animation and yield:
if life == 0:
$Spritezada.play("Dead")
yield($Spritezada, "animation_finished")
print("died")
queue_free()
The above code will play the animation, then halt the execution. When the animation player raises the signal animation_finished
it will resume, print "died"
and set the current node for removal (queue_free
).
By the way, the animation_finished
signal passes a text parameter. If you do not want to use yield
as suggested above, write your code like so:
func _on_Spritezada_animation_finished(anim_name: String):
if anim_name == "Dead":
queue_free()
I believe Godot should be telling you about that missing parameter. If you don't see a message about that, double check you connected the correct signal.

Theraot
- 31,890
- 5
- 57
- 86