Skip to content

Commit

Permalink
Apply incrementalActionSensitivity scaling to continuous-action trim …
Browse files Browse the repository at this point in the history
…inputs.

Also scale by Time.deltaTime for trim and incremental-throttle inputs, as otherwise
the rate of change would depend on framerate.

This makes trim and incremental throttle usable with hat axes (and, I guess, more usable
across the whole range of a proper analog axis). Previously trim would immediately clip
to +/-1 if you tried to control it with a hat axis, which is no use.

Default sensitivity might need increasing now that everything's scaled by the delta-time.
  • Loading branch information
mutability committed Dec 19, 2014
1 parent 55206e0 commit 73a1a56
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions FlightManager.cs
Expand Up @@ -518,19 +518,19 @@ public void EvaluateContinuousAction(ControllerConfiguration controller, Continu
m_Yaw.SetValue(value);
return;
case ContinuousAction.YawTrim:
m_Yaw.SetTrim(Utility.Clamp(m_Yaw.GetTrim() + value, -1.0f, 1.0f));
m_Yaw.SetTrim(Utility.Clamp(m_Yaw.GetTrim() + controller.incrementalActionSensitivity * value * Time.deltaTime, -1.0f, 1.0f));
return;
case ContinuousAction.Pitch:
m_Pitch.SetValue(value);
return;
case ContinuousAction.PitchTrim:
m_Pitch.SetTrim(Utility.Clamp(m_Pitch.GetTrim() + value, -1.0f, 1.0f));
m_Pitch.SetTrim(Utility.Clamp(m_Pitch.GetTrim() + controller.incrementalActionSensitivity * value * Time.deltaTime, -1.0f, 1.0f));
return;
case ContinuousAction.Roll:
m_Roll.SetValue(value);
return;
case ContinuousAction.RollTrim:
m_Roll.SetTrim(Utility.Clamp(m_Roll.GetTrim() + value, -1.0f, 1.0f));
m_Roll.SetTrim(Utility.Clamp(m_Roll.GetTrim() + controller.incrementalActionSensitivity * value * Time.deltaTime, -1.0f, 1.0f));
return;
case ContinuousAction.X:
m_X.SetValue(value);
Expand All @@ -546,10 +546,10 @@ public void EvaluateContinuousAction(ControllerConfiguration controller, Continu
m_Throttle.SetValue(value - state.mainThrottle);
return;
case ContinuousAction.ThrottleIncrement:
m_Throttle.Increment(value * controller.incrementalActionSensitivity);
m_Throttle.Increment(value * controller.incrementalActionSensitivity * Time.deltaTime);
return;
case ContinuousAction.ThrottleDecrement:
m_Throttle.Increment(-value * controller.incrementalActionSensitivity);
m_Throttle.Increment(-value * controller.incrementalActionSensitivity * Time.deltaTime);
return;
case ContinuousAction.WheelThrottle:
m_WheelThrottle.SetMinMaxValues(-1.0f - state.wheelThrottle, 1.0f - state.wheelThrottle);
Expand All @@ -559,10 +559,10 @@ public void EvaluateContinuousAction(ControllerConfiguration controller, Continu
m_WheelSteer.SetValue(value);
return;
case ContinuousAction.WheelThrottleTrim:
m_WheelThrottle.SetTrim(Utility.Clamp(m_WheelThrottle.GetTrim() + value, -1.0f, 1.0f));
m_WheelThrottle.SetTrim(Utility.Clamp(m_WheelThrottle.GetTrim() + value * controller.incrementalActionSensitivity * Time.deltaTime, -1.0f, 1.0f));
return;
case ContinuousAction.WheelSteerTrim:
m_WheelSteer.SetTrim(Utility.Clamp(m_WheelSteer.GetTrim() + value, -1.0f, 1.0f));
m_WheelSteer.SetTrim(Utility.Clamp(m_WheelSteer.GetTrim() + value * controller.incrementalActionSensitivity * Time.deltaTime, -1.0f, 1.0f));
return;
case ContinuousAction.CameraX:
m_CameraHeading.Increment(value);
Expand Down

0 comments on commit 73a1a56

Please sign in to comment.