From 2b0731014385cf26c1fd271b2343987f2482579b Mon Sep 17 00:00:00 2001 From: mackierx111 Date: Thu, 19 Dec 2024 10:08:44 +0900 Subject: [PATCH] apply vehicle input in FixedUpdate --- .../Scripts/Vehicles/VehicleOverrideInputManager.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Assets/AWSIM/Scripts/Vehicles/VehicleOverrideInputManager.cs b/Assets/AWSIM/Scripts/Vehicles/VehicleOverrideInputManager.cs index 4fd2bb70a..d444f5eb3 100644 --- a/Assets/AWSIM/Scripts/Vehicles/VehicleOverrideInputManager.cs +++ b/Assets/AWSIM/Scripts/Vehicles/VehicleOverrideInputManager.cs @@ -29,17 +29,20 @@ public class VehicleOverrideInputManager : MonoBehaviour [SerializeField] Vehicle vehicle; - void Update() + private void FixedUpdate() + { + ApplyInput(); + } + + void ApplyInput() { VehicleInputBase.InputArg inputArg = new VehicleInputBase.InputArg(ControlMode, AutonomousInput.SteeringInput); // Update new input for Autonomous and Manually Inputs. AutonomousInput.OnUpdate(inputArg); ManuallyInput.OnUpdate(inputArg); - } - private void FixedUpdate() - { + // If override input is present, switch new ControlMode. if (ManuallyInput.Overridden) { @@ -61,8 +64,6 @@ private void FixedUpdate() vehicle.AutomaticShiftInput = ManuallyInput.ShiftInput; vehicle.SignalInput = ManuallyInput.TurnSignalInput; } - - // TODO: Implement inputs to the vehicle in the case of other control modes. } } } \ No newline at end of file