RealDocs

FMath::FInterpTo

function Core Since unknown
#include "Math/UnrealMathUtility.h"
Access: public Specifiers: static

Description

Smoothly moves a float toward a target value at a given speed, independent of frame rate. Returns Current unchanged if InterpSpeed is zero or negative.

Signature

static auto FInterpTo(T1 Current, T2 Target, T3 DeltaTime, T4 InterpSpeed)

Parameters

Name Type Description Default
Current T1 The current value.
Target T2 The target value to move toward.
DeltaTime T3 Time elapsed since last call, in seconds.
InterpSpeed T4 Interpolation speed. Higher values reach the target faster.

Return Type

auto

Caveats & Gotchas

  • This is an exponential ease — it approaches the target asymptotically and never reaches it exactly. If you need to snap once close, add a threshold check: if (FMath::IsNearlyEqual(Current, Target, 0.01f)) Current = Target.
  • Passing DeltaTime from Tick directly makes this frame-rate-independent, but very large DeltaTime values (e.g. after a hitch) can cause the value to overshoot. Consider capping DeltaTime.
  • InterpSpeed of 0 returns Current unmodified — useful as a safe no-op when speed is driven by a variable that may be zero.

Example

Smoothly interpolate spring arm length in Tick C++
void AMyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	float TargetArmLength = bIsAiming ? 150.0f : 300.0f;
	SpringArm->TargetArmLength = FMath::FInterpTo(
		SpringArm->TargetArmLength,
		TargetArmLength,
		DeltaTime,
		10.0f
	);
}

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.