UKismetMathLibrary::WeightedMovingAverage_FVector
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Blends a new vector sample with the previous smoothed value to produce the next value in a weighted moving average series. Commonly used to smooth camera or velocity vectors.
Caveats & Gotchas
- • This is stateless — you must store PreviousSample yourself between calls, typically once per Tick.
- • Each axis is blended independently with a linear interpolation, so smoothing a direction vector this way does not renormalize the result; renormalize afterward if you need a unit vector.
- • As with the float overload, Weight is applied per call rather than per second, so smoothing feels different at different frame rates unless you account for DeltaTime yourself.
Signature
static FVector WeightedMovingAverage_FVector(FVector CurrentSample, FVector PreviousSample, float Weight) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| CurrentSample | FVector | The newest raw vector value to blend in. | — |
| PreviousSample | FVector | The previously smoothed vector from the series. | — |
| Weight | float | Blend factor toward CurrentSample; higher values track the current sample more closely. | — |
Return Type
FVector Example
Smooth a camera's look-at target C++
// SmoothedTarget is a member FVector
SmoothedTarget = UKismetMathLibrary::WeightedMovingAverage_FVector(RawTargetLocation, SmoothedTarget, 0.15f);
CameraComponent->SetWorldLocation(SmoothedTarget); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?