How can I make an animation stop and play another

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

hi everyone, so im trying to make a running animation when the player is running but I cant figure it out. (Im pretty new to programming) So i used

if Input.is_action_pressed(“sprint”):
animatedSprite.animation = “running”

But it doesnt work since when the sprint button is used the walking animation plays at the same time so it glitches. How can I make the one animation stop and start playing the other one?

:bust_in_silhouette: Reply From: USBashka

Not enough info. AnimatedSprite cannot play multiple animations simultaneously, so you probably calling animatedSprite.animation = "walking" somwhere else in _process function. If I’m right, you can add if statement like this:

if not Input.is_action_pressed("sprint"):
    animatedSprite.animation = "walking"