animation not playing

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By i.want.to.die

so i have this code:
player:

func on_hit(damage):
$Sprite.play("dano")
current_hp -= damage
if current_hp <= 0:
	ply_dead()
func ply_dead():
$CollisionShape2D.queue_free()
is_dead = true
motion.x = 0
$Sprite.play("dead")
$Timer.start()

enemy:

func _on_Area2D_body_entered(body):
body.on_hit(damage)

it only hits the plyer becouse of collision masks

the animation ‘dano’ does not play when the ply_dead function is atcivated on the enemy’s code

how can i fix this?

:bust_in_silhouette: Reply From: jluini

I think you are playing “dano” and immediately playing “dead” in $Sprite, so you actually never see the “dano” animation.
You could start a timer or wait until the “animation_finished” signal is emitted by the animator, and only then run the “dead” animation on the object.