RealDocs

UBlueprintSpringMathLibrary::VelocitySpringDampVector2D

function Engine Blueprint Since 5.7
#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. Useful for capped-speed UI or screen-space position tracking.

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 CriticalSpringDampVector2D.

Signature

static void VelocitySpringDampVector2D(UPARAM(ref) FVector2D& InOutX, UPARAM(ref) FVector2D& InOutV, UPARAM(ref) FVector2D& InOutVi, const FVector2D& TargetX, float MaxSpeed, float DeltaTime, float SmoothingTime = 0.2f);

Parameters

Name Type Description Default
InOutX FVector2D& The value to be damped; updated in place each call.
InOutV FVector2D& The velocity of the damped value; must be persisted by the caller between calls.
InOutVi FVector2D& The intermediate target velocity; must be persisted by the caller between calls.
TargetX const FVector2D& 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 UI cursor towards a target at a capped speed C++
FVector2D CursorPosition = FVector2D::ZeroVector;
FVector2D CursorVelocity = FVector2D::ZeroVector;
FVector2D CursorIntermediateVelocity = FVector2D::ZeroVector;

void UMyHUDWidget::NativeTick(const FGeometry& MyGeometry, float DeltaTime)
{
    UBlueprintSpringMathLibrary::VelocitySpringDampVector2D(CursorPosition, CursorVelocity, CursorIntermediateVelocity, TargetScreenPosition, /*MaxSpeed=*/800.f, DeltaTime, 0.2f);
}

Version History

Introduced in: 5.7

Version Status Notes
5.7 experimental SpringMath is experimental.

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.