Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/SpringMath
Description
Update a position representing a character given a target velocity using a velocity spring. A velocity spring tracks an intermediate velocity which moves at a maximum acceleration linearly towards a target. This means unlike the "SpringCharacterUpdate", it will take longer to reach a target velocity that is further away from the current velocity.
| Name | VelocitySpringCharacterUpdate |
| Type | function |
| Header File | /Engine/Source/Runtime/Engine/Public/Animation/SpringMath.h |
| Include Path | #include "Animation/SpringMath.h" |
template<typename TVector>
static void VelocitySpringCharacterUpdate
(
TVector & InOutPosition,
TVector & InOutVelocity,
TVector & InOutVelocityIntermediate,
TVector & InOutAcceleration,
TVector TargetVelocity,
float SmoothingTime,
float MaxAcceleration,
float DeltaTime,
float VDeadzone,
float ADeadzone
)
Parameters
| Name | Remarks |
|---|---|
| TVector | The type of vector to use (e.g. FVector2D, FVector4, FVector etc) |
| InOutPosition | The position of the character |
| InOutVelocity | The velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| InOutVelocityIntermediate | The intermediate velocity of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| InOutAcceleration | The acceleration of the character. Needs to be stored and persisted by the caller. Usually initialized to zero and not modified by the caller. |
| TargetVelocity | The target velocity of the character. |
| SmoothingTime | The time over which to smooth velocity. It takes roughly the smoothing time in order for the character to reach the target velocity. |
| MaxAcceleration | Puts a limit on the maximum acceleration that the intermediate velocity can do each frame. If MaxAccel is very large, the behaviour wil lbe the same as SpringCharacterUpdate |
| DeltaTime | The delta time to tick the character |
| VDeadzone | Deadzone for velocity. Current velocity will snap to target velocity when within the deadzone |
| ADeadzone | Deadzone for acceleration. Acceleration will snap to zero when within the deadzone |