RealDocs

UBlueprintSpringMathLibrary::CriticalSpringDampVector2D

function Engine Blueprint Since 5.7
#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 2D UI positions or screen-space coordinates.

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; each axis is damped independently.

Signature

static void CriticalSpringDampVector2D(UPARAM(ref) FVector2D& InOutX, UPARAM(ref) FVector2D& InOutV, const FVector2D& TargetX, 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.
TargetX const FVector2D& 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 widget's screen position towards a target C++
FVector2D WidgetPosition = FVector2D::ZeroVector;
FVector2D WidgetVelocity = FVector2D::ZeroVector;

void UMyHUDWidget::NativeTick(const FGeometry& MyGeometry, float DeltaTime)
{
    UBlueprintSpringMathLibrary::CriticalSpringDampVector2D(WidgetPosition, WidgetVelocity, TargetScreenPosition, DeltaTime, 0.2f);
    SetPositionInViewport(WidgetPosition);
}

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.