UKismetMathLibrary::QuaternionSpringInterp
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Interpolates a quaternion using a damped spring model, producing overshoot and oscillation in rotation. Useful for adding bounce to camera rotations or procedural aim sway.
Caveats & Gotchas
- • FQuaternionSpringState must be a persistent member — not a local variable. It stores angular velocity between frames; resetting it loses the spring's momentum and produces a pop.
- • Input quaternions must be unit quaternions. Passing un-normalized quaternions (e.g. from an imprecise multiplication chain) can produce drift or garbage output. Call FQuat::Normalize() on both Current and Target if their source is not guaranteed normalized.
Signature
static ENGINE_API FQuat QuaternionSpringInterp(FQuat Current, FQuat Target, UPARAM(ref) FQuaternionSpringState& SpringState, float Stiffness, float CriticalDampingFactor, float DeltaTime, float Mass = 1.f, float TargetVelocityAmount = 1.f, bool bInitializeFromTarget = false); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Current | FQuat | Current rotation this frame. | — |
| Target | FQuat | Target rotation to spring toward. | — |
| SpringState | UPARAM(ref) FQuaternionSpringState& | Persistent state struct — one per spring instance. | — |
| Stiffness | float | Spring stiffness. Higher values oscillate faster. | — |
| CriticalDampingFactor | float | Damping ratio. 1 = critically damped (no oscillation). | — |
| DeltaTime | float | Time elapsed since last call. | — |
| Mass | float | Simulated mass. Higher mass means slower angular acceleration. | 1.f |
| TargetVelocityAmount | float | How much the target's angular velocity influences the spring. Set to 0 to smooth noisy input. | 1.f |
| bInitializeFromTarget | bool | If true, seeds Current from Target on first update to avoid an initial impulse. | false |
Return Type
FQuat Example
Spring-follow a bone rotation C++
// Header:
FQuaternionSpringState RotSpring;
// AnimInstance Update:
FQuat NewRot = UKismetMathLibrary::QuaternionSpringInterp(
CurrentRot, TargetBoneQuat,
RotSpring, 80.f, 0.75f, DeltaTime);
BoneTransform.SetRotation(NewRot); Tags
Version History
Introduced in: 4.26
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?