From 5e2a9efc8a27db58911b31fc360c189146d7def7 Mon Sep 17 00:00:00 2001 From: soul Date: Thu, 29 Oct 2026 08:07:30 +0100 Subject: [PATCH] Keyboard turning ramps to full over KeyboardTurnRampTime (0.4 s) so a tap feathers the turn; analog turn passes straight through Release or reversal starts the ramp again from zero (operator request, 2026-10-29: the Longinus lurches). Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Gameplay/ActionGameManager.cs | 6 +++++- Assets/Scripts/ServerShared/HelmInput.cs | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index a75e7ea04..7f6451934 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -201,6 +201,8 @@ public class ActionGameManager : MonoBehaviour private float3 _viewDirection; // The player's face-the-aim state (Left Shift held, Caps Lock latched); Ship.Turn is its only output. private readonly HelmInput _helm = new HelmInput(); + // Seconds a held turn key takes to reach full turn rate. + public float KeyboardTurnRampTime = .4f; private TextMeshProUGUI _faceAimMark; private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups; // The outgoing progress indicators on the player's target: one per lock weapon (its Lock, shown only on a hostile target) @@ -1335,7 +1337,9 @@ public class ActionGameManager : MonoBehaviour { ship.Command.Movement = Input.Player.Move.ReadValue().ToCultMath(); _helm.Held = Input.Player.FaceAim.IsPressed(); - ship.Command.Turn = _helm.Demand(_viewDirection.xz, Input.Player.Turn.ReadValue()); + var turnDigital = Input.Player.Turn.activeControl?.device is UnityEngine.InputSystem.Keyboard; + var turnAxis = _helm.TurnAxis(Input.Player.Turn.ReadValue(), turnDigital, Time.deltaTime, KeyboardTurnRampTime); + ship.Command.Turn = _helm.Demand(_viewDirection.xz, turnAxis); } UpdateMusic(); diff --git a/Assets/Scripts/ServerShared/HelmInput.cs b/Assets/Scripts/ServerShared/HelmInput.cs index 7894f33a3..aa9cd3a03 100644 --- a/Assets/Scripts/ServerShared/HelmInput.cs +++ b/Assets/Scripts/ServerShared/HelmInput.cs @@ -13,6 +13,17 @@ public class HelmInput public void Toggle() => Latched = !Latched; + private float _turnAxis; + + // The turn axis as the helm reads it. A digital input (keys) ramps from zero to full over rampTime so a tap feathers the + // turn; releasing it, or reversing, starts again from zero. An analog input passes straight through. + public float TurnAxis(float raw, bool digital, float dt, float rampTime) + { + if (!digital || rampTime <= 0 || raw == 0) return _turnAxis = raw; + if (sign(raw) != sign(_turnAxis)) _turnAxis = 0; + return _turnAxis = sign(raw) * min(abs(raw), abs(_turnAxis) + dt / rampTime); + } + // The turn the player commands: the aim heading, resolved against the hull at each sim step, or the turn axis. public TurnCommand Demand(float2 aim, float turnAxis) => FaceAim ? TurnCommand.Toward(aim) : TurnCommand.OfRate(clamp(turnAxis, -1f, 1f));