RealDocs

UKismetMathLibrary::Vector4_IsNearlyZero3

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

Description

Returns true if all XYZ components of A are within Tolerance of zero. The W component is not tested. Useful for checking whether a 3D direction vector has degenerated to near-zero before normalizing it.

Caveats & Gotchas

  • W is completely ignored. A vector with a large W component but tiny XYZ will still return true. This can mislead if you are treating W as meaningful (e.g., homogeneous weight).
  • The check is per-component, not on the length: FMath::Abs(X) < Tolerance AND FMath::Abs(Y) < Tolerance AND FMath::Abs(Z) < Tolerance. A vector like (0.0009, 0.0009, 0.0009) with Tolerance=0.001 passes even though its length (~0.00156) is larger than Tolerance.

Signature

static UE_INL_API bool Vector4_IsNearlyZero3(const FVector4& A, float Tolerance = 1.e-4f)

Parameters

Name Type Description Default
A const FVector4& The vector to check.
Tolerance float Maximum absolute value each XYZ component may have and still be considered zero. 1.e-4f

Return Type

bool

Example

Guard normalization to prevent divide-by-zero C++
FVector4 Dir = SomeComputedDirection();
if (!UKismetMathLibrary::Vector4_IsNearlyZero3(Dir))
{
    Dir = Dir / UKismetMathLibrary::Vector4_Size3(Dir);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.