AnimatedSprite2D platformer animation stuck on a single frame

Godot Version

Godot 4.6.3

How do I fix the spin_jumping spin animation only playing a single frame?? What I’ve got here is the snippet of my func _physics_process() that handles the animation side of my CharacterBody2D.

	if velocity.x:
		if p_meter == 1.867:
			$AnimatedSprite2D.play('run')
		else:
			$AnimatedSprite2D.play('walk')

		var frame_rates_by_speed: Array[float] = [1.0, 1.25, 1.5, 2.0, 3.0, 4.0, 6.0, 6.0]
		var index: int = int(abs(velocity.x) / 30)
		index = min(index, 7)
		if is_on_wall() and direction * velocity.x > 0:
			index = 3
		$AnimatedSprite2D.speed_scale = frame_rates_by_speed[index]
	else:
		$AnimatedSprite2D.play('idle')
	
	if direction * sign(velocity.x) == -1:
		$AnimatedSprite2D.play('turn')
	
	$AnimatedSprite2D.flip_h = facing_dir < 0
	
	if not is_on_floor():
		if not spin_jumping:
			if velocity.y > 1:
				$AnimatedSprite2D.play('fall')
			else:
				$AnimatedSprite2D.play('jump')
				jumping = true
		else:
			if $AnimatedSprite2D.animation != 'spin':
				$AnimatedSprite2D.play('spin')
				$AnimatedSprite2D.animation = 'spin'

    move_and_slide()

I also forgot to mention that there is another possibility.

If the animation name is correct and it still shows only one frame, open the spin animation in the SpriteFrames resource and verify:

  • The animation contains multiple frames.
  • The animation’s FPS is greater than 0.
  • The animation is not set up with only a single frame accidentally.

Hope this helps!

Alex

Thank you alex!! advice was exactly what I needed and I got it working now!