UKismetMathLibrary::Normal2D
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns a unit-length copy of the 2D vector without any safety check. This is the unsafe variant — it will produce NaN if called on a zero-length vector.
Caveats & Gotchas
- • Passing a zero or near-zero vector causes a divide-by-zero and produces NaN components. Always check the input or use NormalSafe2D in contexts where the vector length is not guaranteed.
- • The Blueprint display name is 'Normalize 2D' (ScriptMethod NormalUnsafe), which differs from NormalSafe2D — be careful when referencing documentation that uses display names.
Signature
static UE_INL_API FVector2D Normal2D(FVector2D A); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector2D | The 2D vector to normalize. | — |
Return Type
FVector2D Example
Normalize a direction you know is non-zero C++
// Caller guarantees InputDir is non-zero
FVector2D InputDir = FVector2D(3.f, 4.f);
FVector2D UnitDir = UKismetMathLibrary::Normal2D(InputDir);
// UnitDir == (0.6, 0.8) Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?