Topic was automatically imported from the old Question2Answer platform.
Asked By
mbarake
trying to make a simple platformer but the slide and jump animations only play the first frame, i tried every thing (associating the animations with variables and other things and i keep running into the same problem, godot only plays the first frame, however i dont have that problem with the run animation. here is my code)
My best guess is that it’s only playing the first frame because it is constantly switching between the run and slide or jump animations
If the player is pressing right and down, your code will first check if it’s moving right and play the run animations, then checking if it’s sliding and so play the slide animation.
Because godot thinks you are already playing the run animation, it will start the slide animation from the start.
I would recommend combining both times you have an if statement about the horizontal axis. Possibly:
Let me know if that doesn’t work or you need more clarification
hey bro i tried your code, the slide animation plays all the frames but when i spawn it is automatically playing the run animation and when i slide the animations plays all frames but no matter what i do i cant move
mbarake | 2020-10-03 13:06
This might be my bad, but it’s possible that the indentation is slightly weird? See if this makes a difference:
if Input.is_action_pressed(“left”):
velocity.x = -SPEED
$AnimatedSprite.flip_h = true
if Input.is_action_pressed(“down”):
velocity.x = -SPEED * 2
$AnimatedSprite.play(“slide”)
$standingshape.disabled = true
$crouchshape.disabled = false
else:
$AnimatedSprite.play(“run”)