Sprinting animation

Godot Version

4.5

Question

Ask your question here! Try to give as many details as possible.

why isn’t my sprint animation working:

@export var player : Player
@export var animation : AnimationPlayer
@export var Sprite : Sprite2D

func _process(_delta):
	if player.direction == 1:
		Sprite.flip_h = false
	elif player.direction == -1:
		Sprite.flip_h = true

	if abs(player.velocity.x) > 0.0 and not Input.is_action_just_pressed("Sprint"):
		animation.play("Walk")
	elif abs(player.velocity.x) > 0.0 and Input.is_action_pressed("Sprint"):
		animation.play("Sprint")
	else:
		animation.play("Idle")

Because in the first if statement, you check for is_action_just_pressed
Change that to is_action_pressed just like how you check when you’re sprinting.

1 Like