The way disable the Diagonal movement (keypress AW, AS, WD, SD) of the charater in Top down 2D game!
-
I have this problem before, and this is my solution, you can reference it. I tested your script too, and it doesn't allow overrides. Maybe you can change it with dictionary method, but I think it good for beginner.
var direction := Vector2.ZERO var move_speed = Vector2() if Input.is_action_pressed("move_right"): direction.x = 1.0 elif Input.is_action_pressed("move_left"): direction.x = -1.0 if direction.x != 0: move_speed.x = SPEED direction.y = 0 elif Input.is_action_pressed("move_up"): direction.y = -1.0 elif Input.is_action_pressed("move_down"): direction.y = 1.0 if direction.y != 0: move_speed.y = SPEED direction.x = 0 move_and_slide(SPEED * direction)
-
Put ```gdscript
before the code blocks, so the syntax highlighting is on -
@sepTN oh, it's cool
-