UKismetMathLibrary::Normalize2D
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Normalizes a 2D vector in place. If the vector is too small to normalize safely it is set to (0,0) instead.
Caveats & Gotchas
- • Mutates the vector in place rather than returning a new value. In Blueprint, the pin is marked 'ref' — make sure you pass the variable directly rather than a literal.
- • Like NormalSafe2D, the Tolerance is compared against the squared length. Setting it to a linear-distance threshold by mistake will silently produce wrong results.
Signature
static UE_INL_API void Normalize2D(UPARAM(ref) FVector2D& A, float Tolerance = 1.e-8f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | UPARAM(ref) FVector2D& | The vector to normalize in place. | — |
| Tolerance | float | Minimum squared length for normalization to proceed. | 1.e-8f |
Return Type
void Example
Normalize a cached direction vector in place C++
FVector2D MoveDir = PlayerInput.GetRawAxis2D();
UKismetMathLibrary::Normalize2D(MoveDir);
ApplyMovement(MoveDir); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?