UBlueprintSpringMathLibrary::CriticalSpringDampVector
#include "Kismet/BlueprintSpringMathLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Interpolates InOutX towards TargetX using the motion of a critically damped spring, storing the resulting velocity back into InOutV. Commonly used to smooth a camera or follow-target position.
Caveats & Gotchas
- • Marked UE_EXPERIMENTAL(5.7, "SpringMath is experimental") — behaviour and defaults may change in later engine versions.
- • InOutX and InOutV must be persisted by the caller between calls (e.g. as member variables on an actor or component); each axis is damped independently, so uneven per-axis targets can produce a curved rather than straight-line approach.
- • This is functionally equivalent in intent to UKismetMathLibrary::VectorSpringInterp but has a simpler parameter set with no exposed spring-state struct — use the KismetMathLibrary version if you need to reset or inspect spring state explicitly.
Signature
static void CriticalSpringDampVector(UPARAM(ref) FVector& InOutX, UPARAM(ref) FVector& InOutV, const FVector& TargetX, 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. | — |
| TargetX | const FVector& | The goal value to damp towards. | — |
| DeltaTime | float | Timestep in seconds. | — |
| SmoothingTime | float | Smoothing time for the spring. Larger values give more damped behaviour; 0 snaps InOutX to TargetX. | 0.2f |
Return Type
void Example
Smooth a spring-arm target location C++
FVector SmoothedLocation = GetActorLocation();
FVector SmoothedVelocity = FVector::ZeroVector;
void AMyFollowCam::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UBlueprintSpringMathLibrary::CriticalSpringDampVector(SmoothedLocation, SmoothedVelocity, TargetActor->GetActorLocation(), DeltaTime, 0.3f);
SetActorLocation(SmoothedLocation);
} See Also
Tags
Version History
Introduced in: 5.7
| Version | Status | Notes |
|---|---|---|
| 5.7 | experimental | SpringMath is experimental. |
Feedback
Was this helpful?