RealDocs

UKismetMathLibrary::Vector_Normalize

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

Description

Normalizes a vector in place. If the squared length is below Tolerance, the vector is set to (0,0,0). Prefer Normal() when you need the original vector preserved.

Caveats & Gotchas

  • Modifies the input vector directly via a ref parameter. In Blueprint this appears as a 'Normalize In Place' node that writes back through the same pin, which can be confusing if the original un-normalized value is still needed elsewhere.
  • The default tolerance (1.e-8) is tighter than Normal()'s default (1.e-4) because the squared threshold is different. A vector of length 0.0001 (1e-4) passes Normal() but also passes Vector_Normalize since 1e-8 squared is essentially zero. The practical difference is minor in most game code.

Signature

static UE_INL_API void Vector_Normalize(UPARAM(ref) FVector& A, float Tolerance = 1.e-8f);

Parameters

Name Type Description Default
A UPARAM(ref) FVector& The vector to normalize in place. Set to (0,0,0) if too short.
Tolerance float Minimum squared length for normalization. Defaults to 1.e-8. 1.e-8f

Return Type

void

Example

Normalize a direction stored in a variable C++
FVector Velocity = Character->GetVelocity();
UKismetMathLibrary::Vector_Normalize(Velocity);
if (!Velocity.IsZero())
{
    DrawDebugDirectionalArrow(GetWorld(), Origin, Origin + Velocity * 100.f, 10.f, FColor::Green, false, -1.f, 0, 2.f);
}

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.