How do I make all frames of an animation play?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CherryInferno

My run and idle animations always work, but despite having it set to play other animations on inputs they only ever play the first frame. This is whats working for my run and idle:

if x_input != 0:
	$AnimationPlayer.play("Run")
	motion.x += x_input * ACCELERATION * delta
	motion.x = clamp(motion.x, -MAX_SPEED, MAX_SPEED)
	sprite.flip_h = x_input < 0
	
else:
	$AnimationPlayer.play("Idle")`

This is what’s only giving me one frame:

	if Input.is_action_pressed("ui_special"):
		$AnimationPlayer.play("Float")
		motion.y = JUMP_FORCE*AIR_RESISTANCE*4

What do I need to do to make it play the whole thing out? I also have move_and_slide on, I don’t know if that’s got something to do with it.

:bust_in_silhouette: Reply From: AralC

I think the problem here is the you dont call the function play() just one time. When you press the button "ui_special" it does call th func play in every frame so it plays only the first frame. I suggest you to use Input.is_action_just_pressed("ui_special"). I think that will help.

I tried that, but now both the animation and the effect only last for 1 frame before stopping

CherryInferno | 2021-01-10 15:19

:bust_in_silhouette: Reply From: mofri1400

What do I need to do to make it play the whole thing out? I also have ( میز و صندلی کودک ) moveandslide on, I don’t know if that’s got something to do with it.

Yeah, I want it to play it out on loop the same way it does Idle and Run

CherryInferno | 2021-01-10 19:09