Godot Version
4.7
Question
Hello, Godot community!
I have ran into a problem when making an animated walk cycle. The sprites don’t change and the animation isn’t playing.
It was actually working fine at first but then I added the ability to walk up and down and something at some point went wrong.
Here’s the code for the anim movement:
func _physics_process(_delta: float) → void:
if (velocity.x > 1):
sprite_2d.play("right_walk")
elif (velocity.x < -1):
sprite_2d.play("left_walk")
else:
sprite_2d.play("default")
if (velocity.y < -1):
sprite_2d.play("back_walk")
elif (velocity.y > 1):
sprite_2d.play("front_walk")
else:
sprite_2d.play("default")
I’m aware that it’s probably one (or both) of the following problems:
- It’s stuck repeating the first frame and the anim can’t finish
- One of the anims is overriding all others
The catch is that I don’t know how to solve these issues. If anyone has any ideas, please explain potential fixes (*preferrably in simple terms).
*I’ve been using Godot for only 3 days now and don’t have much programming experience overall.
Thank you in advance :]