Help with attacking animation

Godot Version

4.2

Question

I want to make it so when the player is facing a certain way, their attack idle is playing for that direction and then when left click is pressed it plays their actual attacking animation for that direction, but it seems the player cannot leave “attackUpIdle” as long as the previous condition is met. How can I fix this?

if bow_equipped:
	speed = 0
	if mouse_loc_from_player.x >= -25 and mouse_loc_from_player.x <= 25 and mouse_loc_from_player.y < 0:
		sprite.play("attackUpIdle")
		if Input.is_action_just_pressed("left click"):
			sprite.play("attackUp")

Hi!

Can I assume that the block of code you gave is inside _process?

In which case, you’re playing the “attackUpIdle” animation the immediate frame after the click. A few ways you could do it, but the easiest would be to check if the animation is playing and the current animation is attackUp.

if bow_equipped:
	speed = 0
	if mouse_loc_from_player.x >= -25 and mouse_loc_from_player.x <= 25 and mouse_loc_from_player.y < 0:
        if not sprite.is_playing() and sprite.current_animation.animation == "attackUp":
     		sprite.play("attackUpIdle")
		if Input.is_action_just_pressed("left click"):
			sprite.play("attackUp")