Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/FMath
Description
Smooths a value using a critically damped spring. Works for any type that supports basic arithmetic operations.
Note that InSmoothingTime is the time lag when tracking constant motion (so if you tracked a predicted position TargetVel * InSmoothingTime ahead, you'd match the target position)
An approximation is used that is accurate so long as InDeltaTime < 0.5 * InSmoothingTime
When starting from zero velocity, the maximum velocity is reached after time InSmoothingTime * 0.5
| Name | CriticallyDampedSmoothing |
| Type | function |
| Header File | /Engine/Source/Runtime/Core/Public/Math/UnrealMathUtility.h |
| Include Path | #include "Math/UnrealMathUtility.h" |
template<class T>
static void CriticallyDampedSmoothing
(
T & InOutValue,
T & InOutValueRate,
const T & InTargetValue,
const T & InTargetValueRate,
const float InDeltaTime,
const float InSmoothingTime
)
Parameters
| Name | Remarks |
|---|---|
| InOutValue | The value to be smoothed |
| InOutValueRate | The rate of change of the value |
| InTargetValue | The target to smooth towards |
| InTargetValueRate | The target rate of change smooth towards. Note that if this is discontinuous, then the output will have discontinuous velocity too. |
| InDeltaTime | Time interval |
| InSmoothingTime | Timescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero. |