Welcome to the forums @BR__!
I don't know for sure and I only looked through the code quickly, but the issue is likely that the animation is being overridden before it has a chance to play, since the play
function is being called without checking to see if the animation already playing is the desired animation.
To fix this, you can make a function like this:
func change_animation(new_animation):
if $AnimatedSprite.animation == new_animation:
return # do nothing!
# otherwise, play the animation
$AnimatedSprite.play(new_animation)
Then, instead of using $AnimatedSprite.play
, you can instead use change_animation
. For example, you could replace line 30 to change_animation("jump")
and that should fix the issue you are having with the animation.