UKismetMathLibrary::Vector4_Normal3
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns a safe normalized copy of the vector's XYZ components with W set to 0. If the XYZ squared length is below Tolerance, returns (0,0,0,0) instead of dividing by near-zero.
Caveats & Gotchas
- • The returned vector always has W=0 regardless of the input W — if you need to preserve W, copy it back manually after calling this.
- • The zero-vector fallback is (0,0,0,0) not (0,0,0,1), so downstream code that treats W=0 as a direction is fine, but homogeneous-point code expecting W=1 will break silently.
Signature
static UE_INL_API FVector4 Vector4_Normal3(const FVector4& A, float Tolerance = 1.e-4f); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | const FVector4& | The vector to normalize. | — |
| Tolerance | float | Minimum squared length required to normalize. Below this, returns zero vector. | 1.e-4f |
Return Type
FVector4 Example
Safe normalize a direction vector C++
FVector4 Dir(0.0, 3.0, 4.0, 0.0);
FVector4 Norm = UKismetMathLibrary::Vector4_Normal3(Dir);
// Norm == (0, 0.6, 0.8, 0) Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?