Skip to content

Commit

Permalink
Added CancelDeltaTime option
Browse files Browse the repository at this point in the history
  • Loading branch information
glabute committed Sep 5, 2023
1 parent 197c41c commit d88ce46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions com.unity.cinemachine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Renamed InputAxis.DoRecentering() to InputAxis.UpdateRecentering()
- Added API in Deoccluder and ThirdPersonFollow to access which collision objects are impacting the camera position.
- Added ICinemachineTargetGroup.IsValid property to detect deleted groups.
- Added option to disable deltaTime scaling in CinemachineInputAxisProvider.
- Removed CinemachineToolSettings overlay.
- New sample: ThirdPersonWithAimMode showing how to implement a FreeLook camera with Aim mode.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This component makes it easy to control a `CinemachineCamera` in a single player
| __Input Value__ | The input value read during this frame |
| __Accel Time__ | The time it takes for the input value to accelerate to a larger value |
| __Decel Time__ | The time it takes for the input value to decelerate to a smaller value |
| __Cancel Delta Time__ | This will cancel the built-in deltaTime compensation done by the input axis. Enable this if the input value is inherently dependent on frame time. For example, mouse deltas will naturally be bigger for longer frames, so in this case the default deltaTime scaling should be canceled. |

## Creating your own Input Axis Controller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public delegate float ControlValueReader(
public float LegacyGain = 1;
#endif

/// <summary>Enable this if the input value is inherently dependent on frame time.
/// For example, mouse deltas will naturally be bigger for longer frames, so
/// should not normally be scaled by deltaTime.</summary>
[Tooltip("Enable this if the input value is inherently dependent on frame time. "
+ "For example, mouse deltas will naturally be bigger for longer frames, so "
+ "in this case the default deltaTime scaling should be canceled.")]
public bool CancelDeltaTime = false;

/// <inheritdoc />
public float GetValue(
UnityEngine.Object context,
Expand All @@ -158,7 +166,7 @@ public float GetValue(
//catch (ArgumentException e) { Debug.LogError(e.ToString()); }
}
#endif
return inputValue;
return CancelDeltaTime ? inputValue / Time.deltaTime : inputValue;
}

#if CINEMACHINE_UNITY_INPUTSYSTEM
Expand Down

0 comments on commit d88ce46

Please sign in to comment.