Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/FMath
Description
Smooths a value using a spring damper towards a target.
The implementation uses approximations for Exp/Sin/Cos. These are accurate for all sensible values of InUndampedFrequency and DampingRatio so long as InDeltaTime < 1 / InUndampedFrequency (approximately), but are generally well behaved even for larger timesteps etc.
| Name | SpringDamper |
| Type | function |
| Header File | /Engine/Source/Runtime/Core/Public/Math/UnrealMathUtility.h |
| Include Path | #include "Math/UnrealMathUtility.h" |
template<class T>
static void SpringDamper
(
T & InOutValue,
T & InOutValueRate,
const T & InTargetValue,
const T & InTargetValueRate,
const float InDeltaTime,
const float InUndampedFrequency,
const float InDampingRatio
)
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 |
| InUndampedFrequency | Oscillation frequency when there is no damping. Proportional to the square root of the spring stiffness. |
| InDampingRatio | 1 is critical damping. <1 results in under-damped motion (i.e. with overshoot), and >1 results in over-damped motion. |