Skip to content

Commit

Permalink
Add delta time input
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineCharton committed Aug 28, 2023
1 parent f07bc68 commit 22b3e0f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public delegate float ControlValueReader(
+ "Controls the input power. Set it to a negative value to invert the input")]
public float LegacyGain = 1;
#endif
/// <summary>Apply a delta time to the received input value.</summary>
[Tooltip("Apply a delta time to the input value. Set true for controller joysticks and false for mouse.")]
public bool DeltaTimeInput;

/// <inheritdoc />
public float GetValue(
Expand All @@ -146,14 +149,18 @@ public float GetValue(
if (InputAction != null)
{
if (context is CinemachineInputAxisController c)
inputValue = ResolveAndReadInputAction(c, hint) * Gain;
inputValue = DeltaTimeInput ?
ResolveAndReadInputAction(c, hint) * Time.deltaTime * Gain :
ResolveAndReadInputAction(c, hint) * Gain;
}
#endif

#if ENABLE_LEGACY_INPUT_MANAGER
if (inputValue == 0 && !string.IsNullOrEmpty(LegacyInput))
{
try { inputValue = CinemachineCore.GetInputAxis(LegacyInput) * LegacyGain; }
try { inputValue = DeltaTimeInput ?
CinemachineCore.GetInputAxis(LegacyInput) * Time.deltaTime * LegacyGain :
CinemachineCore.GetInputAxis(LegacyInput) * LegacyGain; }
catch (ArgumentException) {}
//catch (ArgumentException e) { Debug.LogError(e.ToString()); }
}
Expand Down

0 comments on commit 22b3e0f

Please sign in to comment.