Godot Version
4
Question
So basically, (I’m new) I’m trying to set up a walk cycle that has just 4 directions:
down, up, left and right.
What I want is very simple, when you’re traveling left for example, it will play the “kid_walk_left” animation. But if you press downwards as well, you will start moving diagonally. But I do not want the walk animation to change until you stop pressing left.
Here’s what I came up with:
I set an input to all the movement keys, so it will only recognize it once, therefore not changing the animation. But if you cycle through the keys while never taking your fingers off completely, you’ll be stuck in the same animation.
if Input.is_action_just_pressed("all_move_keys"):
if Input.is_action_pressed("moveright"):
$AnimatedSprite2d.play("kid_walk_right")
if Input.is_action_pressed("moveleft"):
$AnimatedSprite2d.play("kid_walk_left")
if Input.is_action_pressed("movedown"):
$AnimatedSprite2d.play("kid_walk_down")
if Input.is_action_pressed("moveup"):
$AnimatedSprite2d.play("kid_walk_up")
I know this is like probably super simple, I just don’t know how games normally do it.