RealDocs

UBlueprintSpringMathLibrary::CriticalSpringDampFloat

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. Called once per tick to smoothly chase a moving target without overshoot ringing.

Caveats & Gotchas

  • Marked UE_EXPERIMENTAL(5.7, "SpringMath is experimental") — behaviour and defaults may change in later engine versions.
  • InOutX and InOutV are both in/out parameters that must be stored persistently by the caller (e.g. as member variables); passing fresh zero-initialized locals every call resets the spring state instead of continuing it.
  • A SmoothingTime of 0 snaps InOutX directly to TargetX rather than interpolating — this is a valid way to disable smoothing conditionally, not an edge case to guard against.

Signature

static void CriticalSpringDampFloat(UPARAM(ref) float& InOutX, UPARAM(ref) float& InOutV, const float& TargetX, 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.
TargetX const float& 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 UI meter value towards a target each tick C++
// Members persisted on the owning object
float DisplayedHealth = 100.f;
float DisplayedHealthVelocity = 0.f;

void AMyHUDActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    UBlueprintSpringMathLibrary::CriticalSpringDampFloat(DisplayedHealth, DisplayedHealthVelocity, TargetHealth, DeltaTime, 0.15f);
}

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.