UKismetMathLibrary::Vector_IsNearlyZero
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns true if all components of the vector are within the specified tolerance of zero. Use this instead of checking VSize for a floating-point near-zero guard.
Caveats & Gotchas
- • Tests each component independently against the tolerance, not the vector's total magnitude. A vector like (0, 0, 1e-3) passes if Tolerance >= 1e-3 even though its magnitude is 1e-3.
- • The default tolerance (1e-4) is appropriate for world-space values in centimetre scale but may be too tight or too loose for normalized direction vectors or UI coordinates — always pass an explicit tolerance when the context is not standard world space.
Signature
static UE_INL_API bool Vector_IsNearlyZero(const FVector& A, float Tolerance = 1.e-4f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | const FVector& | The vector to test. | — |
| Tolerance | float | Per-component absolute tolerance. Defaults to 1e-4. | 1.e-4f |
Return Type
bool Example
Guard against normalizing a near-zero velocity C++
FVector Vel = CharacterMovement->Velocity;
if (!UKismetMathLibrary::Vector_IsNearlyZero(Vel))
{
FVector Dir = Vel.GetSafeNormal();
// safe to use Dir
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?