UKismetMathLibrary::DynamicWeightedMovingAverage_Float
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Like WeightedMovingAverage_Float, but the blend weight scales with how far CurrentSample is from PreviousSample, so small noise is smoothed heavily while large jumps are tracked more responsively (or vice versa, depending on how Min/MaxWeight are set).
Caveats & Gotchas
- • This is stateless — you must store PreviousSample yourself between calls.
- • If MinWeight is set higher than MaxWeight, the relationship inverts: small changes will be tracked more responsively than large ones, which is a valid but easy-to-miss configuration.
- • MaxDistance defines the point at which the weight saturates at MaxWeight; values far beyond MaxDistance don't push the weight any further.
Signature
static float DynamicWeightedMovingAverage_Float(float CurrentSample, float PreviousSample, float MaxDistance, float MinWeight, float MaxWeight) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| CurrentSample | float | The newest raw value to blend in. | — |
| PreviousSample | float | The previously smoothed value from the series. | — |
| MaxDistance | float | Distance between samples at which the blend reaches MaxWeight. | — |
| MinWeight | float | Weight used when the distance between samples is small. | — |
| MaxWeight | float | Weight used when the distance between samples is large (at or beyond MaxDistance). | — |
Return Type
float Example
Smooth small jitter but snap quickly to large movements C++
// SmoothedPosition is a member float (e.g. a single tracked axis)
SmoothedPosition = UKismetMathLibrary::DynamicWeightedMovingAverage_Float(RawPosition, SmoothedPosition, /*MaxDistance=*/50.f, /*MinWeight=*/0.05f, /*MaxWeight=*/0.8f); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?