UBlueprintSpringMathLibrary::VelocitySpringDampVector
#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. Commonly used for a follow-camera or AI positioning that should not exceed a maximum approach speed.
Caveats & Gotchas
- • Marked UE_EXPERIMENTAL(5.7, "SpringMath is experimental") — behaviour and defaults may change in later engine versions.
- • Requires three persistent in/out state variables (InOutX, InOutV, InOutVi); dropping or resetting InOutVi produces motion indistinguishable from CriticalSpringDampVector rather than the intended capped-speed behaviour.
- • MaxSpeed is a hard cap on approach speed, not a target cruising speed — small SmoothingTime values combined with a low MaxSpeed can make the value appear to move at a constant speed rather than easing in and out.
Signature
static void VelocitySpringDampVector(UPARAM(ref) FVector& InOutX, UPARAM(ref) FVector& InOutV, UPARAM(ref) FVector& InOutVi, const FVector& TargetX, float MaxSpeed, float DeltaTime, float SmoothingTime = 0.2f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOutX | FVector& | The value to be damped; updated in place each call. | — |
| InOutV | FVector& | The velocity of the damped value; must be persisted by the caller between calls. | — |
| InOutVi | FVector& | The intermediate target velocity; must be persisted by the caller between calls. | — |
| TargetX | const FVector& | 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
Move a follow point at a capped maximum speed C++
FVector FollowPosition = GetActorLocation();
FVector FollowVelocity = FVector::ZeroVector;
FVector FollowIntermediateVelocity = FVector::ZeroVector;
void AFollower::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UBlueprintSpringMathLibrary::VelocitySpringDampVector(FollowPosition, FollowVelocity, FollowIntermediateVelocity, TargetActor->GetActorLocation(), /*MaxSpeed=*/600.f, DeltaTime, 0.3f);
SetActorLocation(FollowPosition);
} See Also
Tags
Version History
Introduced in: 5.7
| Version | Status | Notes |
|---|---|---|
| 5.7 | experimental | SpringMath is experimental. |
Feedback
Was this helpful?