Navigation
API > API/Plugins > API/Plugins/GameplayCameras
Implements a critically damped spring-mass system. See https://en.wikipedia.org/wiki/Damping
Important notes:
- A critically damped spring-mass system converges as fast as possible towards its state of equilibrium without overshooting and/or oscillating. That's the theory, though. In practice, probably because of floating point precision, the system can slightly overshoot, so we clamp the result when it's just about to "settle". See the `GameplayCameras.CriticalDamper.StabilizationThreshold_ cvar for tweaking how that happens.
- In this implementation, the state of equilibrium is 0 (zero). That is, the target that the system is trying to reach is 0. In most practical cases, however, we want to converge towards an arbitrary value, which can even move if the system is being "dragged around". The different overloads of the `Update_ method are there for these different use-cases. Don't mix and match calls, though: it's recommended to stick to one of these overloads.
- See the math notes in the corresponding cpp file for details about the algorithm and its implementation.
| Name | FCriticalDamper |
| Type | struct |
| Header File | /Engine/Plugins/Cameras/GameplayCameras/Source/GameplayCameras/Public/Math/CriticalDamper.h |
| Include Path | #include "Math/CriticalDamper.h" |
Syntax
struct FCriticalDamper
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Math/CriticalDamper.h | |||
FCriticalDamper
(
float InW0 |
Math/CriticalDamper.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| W0 | float | Angular frequency of the oscillator. | Math/CriticalDamper.h | |
| X0 | float | Initial position of the spring-mass system, aka the previous frame's position. | Math/CriticalDamper.h | |
| X0Derivative | float | Initial velocity of the spring-mass system, aka the previous frame's velocity. | Math/CriticalDamper.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
float GetW0 () |
Gets the damping factor. | Math/CriticalDamper.h | |
float GetX0() |
Gets the last position of the spring-mass system. | Math/CriticalDamper.h | |
float GetX0Derivative() |
Gets the last velocity of the spring-mass system. | Math/CriticalDamper.h | |
void Reset
(
float InX0, |
Resets the initial conditions (aka the previous frame's state) of the spring-mass system. | Math/CriticalDamper.h | |
void Serialize
(
FArchive& Ar |
Saves or loads the state of this critical damper. | Math/CriticalDamper.h | |
void SetW0
(
float InW0 |
Sets the damping factor. | Math/CriticalDamper.h | |
float Update
(
float DeltaTime |
Updates the system to make it converge towards 0. | Math/CriticalDamper.h | |
float Update
(
float X, |
Updates the system, given a possibly forced position the system was moved to. | Math/CriticalDamper.h | |
float Update
(
float PreviousDamped, |
Updates the system for damping towards arbitrary non-zero values. | Math/CriticalDamper.h |