UKismetMathLibrary::Normal
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns a unit-length copy of the vector, or (0,0,0) if the squared length is below Tolerance. This is the safe normalization path — it never divides by zero.
Caveats & Gotchas
- • Returns the zero vector (0,0,0) when the input is too short, not a NaN or assertion failure. Always check the result before use if the input could be near-zero — calling code often silently ignores a zero direction and produces subtle movement bugs.
- • Tolerance is applied to the *squared* length, so a default of 1.e-4 means vectors shorter than ~0.01 world units are treated as zero. Reduce the tolerance only if you know your input vectors are reliably non-degenerate.
Signature
static UE_INL_API FVector Normal(FVector A, float Tolerance = 1.e-4f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector | The vector to normalize. | — |
| Tolerance | float | Minimum squared vector length required for normalization. Defaults to 1.e-4. | 1.e-4f |
Return Type
FVector Example
Normalize a launch direction C++
FVector LaunchDir = TargetLocation - OwnerLocation;
FVector SafeDir = UKismetMathLibrary::Normal(LaunchDir);
if (!SafeDir.IsZero())
{
ProjectileComp->Velocity = SafeDir * LaunchSpeed;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?