|Attention||Topic was automatically imported from the old Question2Answer platform.|
Hi Everyone, I am making a 2d platformer in Godot engine. I have came across on issue.
In a lot of platformers when you try to run and you are on a wall the character plays idle animation. I wanted to implement this in my game. I tried to code that when I am on a wall
play the idle animation
if is_on_wall(): $AnimatedSprite.play("idle")
But when I run this when the player is on a wall it plays the idle animation but it only the first frame
I also tried this:
if velocity.x == 0:
But is still plays the running animation because I am using a else statement for running animation
Can Someone help me with this?
I’m going to go out on a limb here and guess that the code
$AnimatedSprite.play("idle") is being run in the
_physics_process() function. If that’s true, then first check for whether the animation is playing. If not, then play it:
if is_on_wall() and $AnimatedSprite.animation != "idle": $AnimatedSprite.play("idle")
Ertain | 2022-04-19 04:45
I tried this out and it worked but the problem was it only played the first frame of the idle animation
TopBat69 | 2022-04-20 06:12
Hmm, does the animation not loop? Is that expected? Or rather, would it be fine if the “idle” animation looped?
Ertain | 2022-04-20 06:34