UKismetMathLibrary::Vector_IsNAN
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns true if any component of the vector is Not-a-Number (NaN). Primarily used for defensive validation of values arriving from physics, animation, or external data.
Caveats & Gotchas
- • A NaN in any single component propagates to all subsequent arithmetic operations on the vector. Catching NaN early — especially before passing to physics or AI — prevents silent state corruption that is very hard to debug.
- • This function only detects NaN, not Inf. Use FMath::IsFinite per-component if you also need to catch infinity values (e.g., from a divide-by-zero on a FVector component).
Signature
static UE_INL_API bool Vector_IsNAN(const FVector& A); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector | The vector to test for NaN components. | — |
Return Type
bool Example
Validate physics output before applying to transform C++
FVector SimulatedVel = PhysicsBody->GetPhysicsLinearVelocity();
if (UKismetMathLibrary::Vector_IsNAN(SimulatedVel))
{
UE_LOG(LogTemp, Error, TEXT("Physics velocity NaN detected — resetting"));
PhysicsBody->SetPhysicsLinearVelocity(FVector::ZeroVector);
return;
}
ApplyVelocity(SimulatedVel); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?