Godot Versio4.5.1
Question
I have been making a game without the use of tutorials for once and have a better understanding of Godot coding, but I am still not a great architect. While the following code works with my directional movement to stop the character entirely (my desired effect) when input is more than two directions (left and up for example), it is probably the wrong/placeholder way to do it. I’ve seen other ways that choose the direction using “abs” for absolute direction, but this is not what I want considering it chooses between which direction the player will go when two inputs are simultaneously pressed. This is my original genius architecture to solve this problem. However, is there a better way?
Thank you.
if Input.is_action_pressed("left") and Input.is_action_pressed("up"):
direction.y = 0
direction.x = 0
if Input.is_action_pressed("left") and Input.is_action_pressed("down"):
direction.y = 0
direction.x = 0
if Input.is_action_pressed("right") and Input.is_action_pressed("up"):
direction.y = 0
direction.x = 0
if Input.is_action_pressed("right") and Input.is_action_pressed("down"):
direction.y = 0
direction.x = 0