RealDocs

UKismetMathLibrary::DynamicWeightedMovingAverage_FRotator

function Engine Blueprint Since unknown
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Like WeightedMovingAverage_FRotator, but the blend weight scales with how far CurrentSample is from PreviousSample, so small rotational jitter is smoothed heavily while large rotation changes are tracked more responsively.

Caveats & Gotchas

  • This is stateless — you must store PreviousSample yourself between calls.
  • Like the non-dynamic overload, blending is component-wise on pitch/yaw/roll rather than quaternion slerp, so it can behave oddly near the ±180° wraparound.
  • MaxDistance is compared against a per-axis rotational distance, not a true angular distance between orientations, so a large single-axis change can dominate the weight calculation even if the overall reorientation is small.

Signature

static FRotator DynamicWeightedMovingAverage_FRotator(FRotator CurrentSample, FRotator PreviousSample, float MaxDistance, float MinWeight, float MaxWeight)

Parameters

Name Type Description Default
CurrentSample FRotator The newest raw rotation to blend in.
PreviousSample FRotator The previously smoothed rotation from the series.
MaxDistance float Distance between samples (in degrees) 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

FRotator

Example

Smooth turret aim with adaptive responsiveness C++
SmoothedAim = UKismetMathLibrary::DynamicWeightedMovingAverage_FRotator(DesiredAim, SmoothedAim, /*MaxDistance=*/30.f, /*MinWeight=*/0.05f, /*MaxWeight=*/0.6f);
TurretMesh->SetRelativeRotation(SmoothedAim);

Tags

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.