RealDocs

UKismetMathLibrary::Vector_IsUnit

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

Description

Returns true if the vector's squared length is within the specified tolerance of 1.0, confirming it is normalized. Avoids the sqrt that VSize would require for the same check.

Caveats & Gotchas

  • The tolerance parameter is applied to the squared length (|A|^2 - 1), not the length itself. A tolerance of 1e-4 on the squared length corresponds to a much smaller tolerance on the actual length — be aware of this when choosing a custom tolerance value.
  • The parameter name in the header contains a typo ("SquaredLenthTolerance" — missing the 'g'), which is visible in IDE autocompletion. The behaviour is correct regardless of the name.

Signature

static UE_INL_API bool Vector_IsUnit(const FVector& A, float SquaredLenthTolerance = 1.e-4f);

Parameters

Name Type Description Default
A FVector The vector to test.
SquaredLenthTolerance float Tolerance applied to the squared length difference from 1.0. Defaults to 1e-4. 1.e-4f

Return Type

bool

Example

Assert that a direction vector is normalized before dot product C++
ensure(UKismetMathLibrary::Vector_IsUnit(ShotDirection));
double Dot = FVector::DotProduct(ShotDirection, AimDirection);

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.