Running animation properly

Godot Version

4.4

Question

I am getting some problems about how to design each frame within an animation. I am concerning about the ATTACKING animation; following there are the sprites i am using:

when I play the animation It looks like just he 0th frame is displayed ans suddenly animation ends

I got to try the following code:

if attack == true and is_on_floor() and anim_Sprite2D.get_animation() != "ATT":
			
		anim_Sprite2D.play("ATT")

but It keeps stoping to the first frame..

I tryed to access to the method:

func _on_animated_sprite_2d_animation_finished(animation_name):
	        print('xxXXxxXX')
		print($AnimatedSprite2D.animation)

But nothig is printed…It looks like the funtion never get called…

So it’s not animating at all? Just stuck on the first frame?

Does the animation play in the editor?

Without more information about your project, it’s hard to say for sure—but have you made sure the animation is set to loop?

ok, at now the animation is running when I click on correct button,but nethereless the animation defined within AnimatedSprite2D should not to loop, but It does…

probably i understood the mistake…
i defined this to get when is attack button is pressed:

if Input.is_action_pressed("ATT") and is_on_floor() :
		attack=true

later I define this condition:

if attack == true and is_on_floor(): 
		anim_Sprite2D.play("ATT")

i think the problem is that as this this come to be true evry frame (also while animation is going up) the animation come to be repeated always

I would suggest trying something like this:

if attack == true and is_on_floor(): 
  if not anim_Sprite2D.is_playing():
    anim_Sprite2D.play("ATT")

You would need to turn off looping for this to work.

mmm, at now I have:

if attack == true and is_on_floor():
		if not anim_Sprite2D.is_playing():
			anim_Sprite2D.play("ATT")

by trying so, It looks like no attack animation runs; maybe the problem is due to the fact the anim_Sprite2D is_playing the IDLE animation so that. anim_Sprite2D.is_playing() is true; maybe is there way to specify what exactly animation is playing??..i guess…