Fixed input from controller

This commit is contained in:
2025-01-04 23:36:17 -06:00
parent 4303aafb59
commit 750719ff88
3 changed files with 19 additions and 15 deletions

View File

@@ -27,22 +27,21 @@ func updateMovement(delta) -> void:
if(dir.x != 0 or dir.y != 0):
velocity.x = dir.x * speed * delta;
velocity.z = dir.y * speed * delta;
print(dir.length());
# Update direction
if(dir.x > 0):
if(
dir.y == 0 or
(dir.y < 0 and direction == Direction.SOUTH) or
(dir.y > 0 and direction == Direction.NORTH)
):
direction = Direction.EAST;
elif (dir.x < 0):
if(
dir.y == 0 or
(dir.y < 0 and direction == Direction.SOUTH) or
(dir.y > 0 and direction == Direction.NORTH)
):
direction = Direction.WEST;
if(dir.x >= abs(dir.y) and(
dir.y == 0 or
(dir.y > 0 and direction != Direction.SOUTH) or
(dir.y < 0 and direction != Direction.NORTH)
)):
direction = Direction.EAST;
elif (dir.x <= -abs(dir.y) and (
dir.y == 0 or
(dir.y > 0 and direction != Direction.SOUTH) or
(dir.y < 0 and direction != Direction.NORTH)
)):
direction = Direction.WEST;
elif (dir.y > 0):
direction = Direction.SOUTH;
elif (dir.y < 0):