RealDocs

FVector::IsNearlyZero

function Core Since unknown
#include "Math/Vector.h"
Access: public Specifiers: const

Description

Returns true if all three components are within Tolerance of zero. Useful for checking if a velocity or direction vector has become negligible.

Signature

bool IsNearlyZero(T Tolerance = UE_KINDA_SMALL_NUMBER) const

Parameters

Name Type Description Default
Tolerance float Maximum absolute value for each component to be considered nearly zero. Defaults to UE_KINDA_SMALL_NUMBER (1e-4). UE_KINDA_SMALL_NUMBER

Return Type

bool

Caveats & Gotchas

  • Tests each component independently against Tolerance — a vector with one large component and two near-zero components will return false.
  • The default tolerance UE_KINDA_SMALL_NUMBER (1e-4) is more lenient than FMath::IsNearlyZero's default. This is intentional for typical vector usage in gameplay.
  • For pure zero checks (no tolerance), use IsZero() instead — it performs an exact equality test.

Example

Guard direction use after interp C++
FVector Velocity = GetCharacterMovement()->Velocity;
if (!Velocity.IsNearlyZero())
{
	FVector FacingDir = Velocity.GetSafeNormal();
	SetActorRotation(FacingDir.Rotation());
}

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.