RealDocs

FMath::ExponentialSmoothingApprox

function Core Since 4.20
#include "Math/UnrealMathUtility.h"
Access: public Specifiers: staticconstexpr

Description

Smooths a value towards a target using an exponential decay approximation. Uses InvExpApprox internally which is cheaper than a true exp() but still frame-rate independent.

Caveats & Gotchas

  • The approximation is accurate when InDeltaTime < InSmoothingTime. At very large delta times relative to InSmoothingTime the approximation diverges from true exponential — prefer CriticallyDampedSmoothing or SpringDamper when frames may stall.
  • When InSmoothingTime is zero (or near UE_KINDA_SMALL_NUMBER), the value is snapped immediately to InTargetValue without smoothing.
  • This function tracks velocity-independent targets only — it has no notion of target velocity. If your target is itself moving, use CriticallyDampedSmoothing to avoid permanent lag.

Signature

template< class T >
static constexpr void ExponentialSmoothingApprox(T& InOutValue, const T& InTargetValue, const float InDeltaTime, const float InSmoothingTime)

Parameters

Name Type Description Default
InOutValue T& The value to be smoothed. Modified in place.
InTargetValue const T& The target value to smooth towards.
InDeltaTime const float Elapsed time since last update.
InSmoothingTime const float Timescale over which to smooth. Larger values mean more smoothed behaviour. Can be zero.

Return Type

void

Example

Smooth a rotation yaw towards a target each tick C++
void AMyPawn::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    FMath::ExponentialSmoothingApprox(CurrentYaw, TargetYaw, DeltaTime, 0.1f);
    SetActorRotation(FRotator(0.f, CurrentYaw, 0.f));
}

Version History

Introduced in: 4.20

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.