Skip to content

Commit 458847e

Browse files
committed
Allow analog movement to work with automovers
1 parent 3c6a010 commit 458847e

File tree

1 file changed

+20
-9
lines changed
  • Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Automovers/Controller

1 file changed

+20
-9
lines changed

Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Automovers/Controller/Controller.lua

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,17 +1042,28 @@ automoverActorFunctions.updateDirectionsFromActorControllerInput = function(self
10421042

10431043
actorData.direction = Directions.None;
10441044

1045-
if not actorController:IsState(Controller.PIE_MENU_ACTIVE) then
1046-
if actorController:IsState(Controller.PRESS_UP) or actorController:IsState(Controller.HOLD_UP) then
1047-
actorData.direction = Directions.Up;
1048-
elseif actorController:IsState(Controller.PRESS_DOWN) or actorController:IsState(Controller.HOLD_DOWN) then
1049-
actorData.direction = Directions.Down;
1050-
elseif actorController:IsState(Controller.PRESS_LEFT) or actorController:IsState(Controller.HOLD_LEFT) then
1051-
actorData.direction = Directions.Left;
1052-
elseif actorController:IsState(Controller.PRESS_RIGHT) or actorController:IsState(Controller.HOLD_RIGHT) then
1053-
actorData.direction = Directions.Right;
1045+
local deadZone = 0.1;
1046+
local analogMove = actorController.AnalogMove;
1047+
if analogMove:MagnitudeIsGreaterThan(deadZone) then
1048+
if math.abs(analogMove.X) < math.abs(analogMove.Y) then
1049+
actorData.direction = analogMove.Y > 0 and Directions.Down or Directions.Up;
1050+
else
1051+
actorData.direction = analogMove.X > 0 and Directions.Right or Directions.Left;
1052+
end
1053+
else
1054+
if not actorController:IsState(Controller.PIE_MENU_ACTIVE) then
1055+
if actorController:IsState(Controller.PRESS_UP) or actorController:IsState(Controller.HOLD_UP) then
1056+
actorData.direction = Directions.Up;
1057+
elseif actorController:IsState(Controller.PRESS_DOWN) or actorController:IsState(Controller.HOLD_DOWN) then
1058+
actorData.direction = Directions.Down;
1059+
elseif actorController:IsState(Controller.PRESS_LEFT) or actorController:IsState(Controller.HOLD_LEFT) then
1060+
actorData.direction = Directions.Left;
1061+
elseif actorController:IsState(Controller.PRESS_RIGHT) or actorController:IsState(Controller.HOLD_RIGHT) then
1062+
actorData.direction = Directions.Right;
1063+
end
10541064
end
10551065
end
1066+
10561067
if actorData.movementMode ~= self.movementModes.unstickActor then
10571068
if actorData.direction == Directions.None and actorData.movementMode ~= self.movementModes.leaveAutomovers then
10581069
actorData.movementMode = self.movementModes.freeze;

0 commit comments

Comments
 (0)