UKismetMathLibrary::SetFloatSpringStateVelocity
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Directly overwrites the velocity component of a float spring's internal state without affecting its current value or previous-target tracking. Useful for injecting an external impulse, such as recoil or an impact, into an ongoing spring interpolation.
Caveats & Gotchas
- • Does not reset PrevTarget or bPrevTargetValid — only the Velocity field is written, so the spring continues tracking its existing target after the call.
- • Calling this every frame instead of only on impulse events fights the spring's own velocity calculation in FloatSpringInterp and produces jittery, unpredictable motion.
Signature
static void SetFloatSpringStateVelocity(UPARAM(ref) FFloatSpringState& SpringState, float Velocity) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| SpringState | FFloatSpringState& | The spring state to modify. | — |
| Velocity | float | The velocity value to assign to the spring's internal state. | — |
Return Type
void Example
Inject a recoil impulse into a spring-smoothed camera kick C++
void AMyWeapon::ApplyRecoilImpulse()
{
UKismetMathLibrary::SetFloatSpringStateVelocity(RecoilSpringState, -50.f);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?