UKismetMathLibrary::WeightedMovingAverage_Float
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Blends a new sample with the previous smoothed value to produce the next value in a weighted moving average series, useful for smoothing noisy per-frame float values.
Caveats & Gotchas
- • This is stateless — you must store PreviousSample yourself (e.g. in a member variable) between calls, typically once per Tick.
- • Weight is not frame-rate independent: the same Weight value produces different amounts of smoothing at 30 FPS versus 120 FPS since it's applied per call, not per second.
- • For smoothing that adapts its strength based on how much the value is changing, use DynamicWeightedMovingAverage_Float instead.
Signature
static float WeightedMovingAverage_Float(float CurrentSample, float PreviousSample, float Weight) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| CurrentSample | float | The newest raw value to blend in. | — |
| PreviousSample | float | The previously smoothed value from the series. | — |
| Weight | float | Blend factor toward CurrentSample; higher values track the current sample more closely. | — |
Return Type
float Example
Smooth a noisy sensor reading each tick C++
// SmoothedSpeed is a member float, initialized once
SmoothedSpeed = UKismetMathLibrary::WeightedMovingAverage_Float(RawSpeed, SmoothedSpeed, 0.1f); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?