UBlueprintSpringMathLibrary::VelocitySpringDampFloat
#include "Kismet/BlueprintSpringMathLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Damps InOutX towards TargetX using a target that follows a fixed linear velocity, giving control over interpolation speed via MaxSpeed while still producing smoothed motion. Use this instead of CriticalSpringDampFloat when you need to cap the approach speed explicitly.
Caveats & Gotchas
- • Marked UE_EXPERIMENTAL(5.7, "SpringMath is experimental") — behaviour and defaults may change in later engine versions.
- • Takes three persistent in/out state variables (InOutX, InOutV, InOutVi) rather than two — omitting InOutVi or re-zeroing it every tick breaks the velocity tracking that distinguishes this from the plain critical spring.
- • A SmoothingTime of 0 produces a linear interpolation from X to TargetX capped at MaxSpeed, not a snap — this differs from the critical-spring functions where 0 means an instant snap.
Signature
static void VelocitySpringDampFloat(UPARAM(ref) float& InOutX, UPARAM(ref) float& InOutV, UPARAM(ref) float& InOutVi, float TargetX, float MaxSpeed, float DeltaTime, float SmoothingTime = 0.2f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOutX | float& | The value to be damped; updated in place each call. | — |
| InOutV | float& | The velocity of the damped value; must be persisted by the caller between calls. | — |
| InOutVi | float& | The intermediate target velocity; must be persisted by the caller between calls. | — |
| TargetX | float | The target value of X to damp towards. | — |
| MaxSpeed | float | The desired speed to achieve while damping towards X. | — |
| DeltaTime | float | Timestep in seconds. | — |
| SmoothingTime | float | Smoothing time while damping towards X. A value of 0 gives a linear interpolation of X to TargetX. | 0.2f |
Return Type
void Example
Damp a value with a capped approach speed C++
float Value = 0.f, Velocity = 0.f, IntermediateVelocity = 0.f;
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UBlueprintSpringMathLibrary::VelocitySpringDampFloat(Value, Velocity, IntermediateVelocity, TargetValue, /*MaxSpeed=*/50.f, DeltaTime, 0.25f);
} See Also
Tags
Version History
Introduced in: 5.7
| Version | Status | Notes |
|---|---|---|
| 5.7 | experimental | SpringMath is experimental. |
Feedback
Was this helpful?