RealDocs

UKismetMathLibrary::WeightedMovingAverage_FRotator

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

Description

Blends a new rotation sample with the previous smoothed value to produce the next value in a weighted moving average series, useful for smoothing camera or aim rotations.

Caveats & Gotchas

  • This is stateless — you must store PreviousSample yourself between calls, typically once per Tick.
  • Blending is done component-wise on pitch/yaw/roll rather than via quaternion slerp, so it can behave oddly near the ±180° wraparound (e.g. averaging 179° and -179° does not smoothly cross 180°).
  • Weight is applied per call rather than per second, so the amount of smoothing shifts with frame rate unless you factor in DeltaTime yourself.

Signature

static FRotator WeightedMovingAverage_FRotator(FRotator CurrentSample, FRotator PreviousSample, float Weight)

Parameters

Name Type Description Default
CurrentSample FRotator The newest raw rotation to blend in.
PreviousSample FRotator The previously smoothed rotation from the series.
Weight float Blend factor toward CurrentSample; higher values track the current sample more closely.

Return Type

FRotator

Example

Smooth camera rotation while following a target C++
// SmoothedRotation is a member FRotator
SmoothedRotation = UKismetMathLibrary::WeightedMovingAverage_FRotator(DesiredRotation, SmoothedRotation, 0.2f);
SpringArmComponent->SetWorldRotation(SmoothedRotation);

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.