UBlueprintSpringMathLibrary::CriticalSpringDampAngle
#include "Kismet/BlueprintSpringMathLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Interpolates InOutAngle towards TargetAngle using the motion of a critically damped spring, storing the resulting angular velocity back into InOutAngularVelocity. Intended for smoothing a single scalar angle rather than a full rotation.
Caveats & Gotchas
- • Marked UE_EXPERIMENTAL(5.7, "SpringMath is experimental") — behaviour and defaults may change in later engine versions.
- • Unlike CriticalSpringDampRotator, this operates on a single angle and does not perform any shortest-path wraparound handling across the 0/360 boundary — angles near that boundary can spring the long way around unless you normalize the delta yourself first.
- • InOutAngle and InOutAngularVelocity must be persisted by the caller between calls; resetting them each tick discards the spring's momentum.
Signature
static void CriticalSpringDampAngle(UPARAM(ref) float& InOutAngle, UPARAM(ref) float& InOutAngularVelocity, const float& TargetAngle, float DeltaTime, float SmoothingTime = 0.2f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOutAngle | float& | The angle to be damped, in degrees; updated in place each call. | — |
| InOutAngularVelocity | float& | The angular velocity in deg/s; must be persisted by the caller between calls. | — |
| TargetAngle | const float& | The goal angle to damp towards, in degrees. | — |
| DeltaTime | float | Timestep in seconds. | — |
| SmoothingTime | float | Smoothing time for the spring. Larger values give more damped behaviour; 0 snaps InOutAngle to TargetAngle. | 0.2f |
Return Type
void Example
Smooth a turret's aim angle towards a target C++
float CurrentAimAngle = 0.f;
float AimAngularVelocity = 0.f;
void ATurret::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UBlueprintSpringMathLibrary::CriticalSpringDampAngle(CurrentAimAngle, AimAngularVelocity, DesiredAimAngle, DeltaTime, 0.25f);
} See Also
Tags
Version History
Introduced in: 5.7
| Version | Status | Notes |
|---|---|---|
| 5.7 | experimental | SpringMath is experimental. |
Feedback
Was this helpful?