UBlueprintSpringMathLibrary::SpringCharacterUpdate
#include "Kismet/BlueprintSpringMathLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Advances a character's position toward a target velocity using a damped spring, smoothing out sudden velocity changes rather than snapping to them instantly. Intended as a lightweight alternative to a full movement component for simple custom motion.
Caveats & Gotchas
- • Marked UE_EXPERIMENTAL(5.7, "SpringMath is experimental") — behaviour and defaults may change in later engine versions.
- • InOutVelocity and InOutAcceleration are caller-owned state that must persist between calls (e.g. as member variables) — passing fresh zeroed locals every tick defeats the spring and produces jittery motion.
- • Unlike VelocitySpringCharacterUpdate, this function has no maximum acceleration clamp, so a large TargetVelocity change combined with a short SmoothingTime can produce very high instantaneous acceleration.
Signature
static void SpringCharacterUpdate(UPARAM(ref) FVector& InOutPosition, UPARAM(ref) FVector& InOutVelocity, UPARAM(ref) FVector& InOutAcceleration, const FVector& TargetVelocity, float DeltaTime, float SmoothingTime = 0.2f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOutPosition | FVector& | The position of the character; updated in place each call. | — |
| InOutVelocity | FVector& | The velocity of the character. Must be stored and persisted by the caller between calls, usually starting at zero. | — |
| InOutAcceleration | FVector& | The acceleration of the character. Must be stored and persisted by the caller between calls, usually starting at zero. | — |
| TargetVelocity | const FVector& | The target velocity of the character. | — |
| DeltaTime | float | The delta time to tick the character. | — |
| SmoothingTime | float | The time over which to smooth velocity; it takes roughly this long for the character to reach the target velocity. | 0.2f |
Return Type
void Example
Advance a character position with a damped spring C++
FVector Position = GetActorLocation();
FVector Velocity = FVector::ZeroVector;
FVector Acceleration = FVector::ZeroVector;
void AMyCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UBlueprintSpringMathLibrary::SpringCharacterUpdate(Position, Velocity, Acceleration, DesiredVelocity, DeltaTime, 0.25f);
SetActorLocation(Position);
} Tags
Version History
Introduced in: 5.7
| Version | Status | Notes |
|---|---|---|
| 5.7 | experimental | SpringMath is experimental. |
Feedback
Was this helpful?