UKismetMathLibrary::MakeRotFromZ
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Builds a rotator whose up axis aligns with the given vector, leaving X and Y arbitrary but orthonormal. Useful for aligning decals or objects to a surface normal.
Caveats & Gotchas
- • When the desired Z axis is nearly parallel to world-up (0,0,1), the resulting X and Y orientations may flip unexpectedly due to Gram-Schmidt instability near the pole.
- • X and Y axes are not deterministic across engine versions; use MakeRotFromZX or MakeRotFromZY if you need a specific secondary axis.
Signature
static UE_INL_API FRotator MakeRotFromZ(const FVector& Z); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Z | const FVector& | The desired up (Z) axis direction. Does not need to be normalized. | — |
Return Type
FRotator Example
Align a decal to a surface normal C++
FVector SurfaceNormal = HitResult.ImpactNormal;
FRotator DecalRot = UKismetMathLibrary::MakeRotFromZ(SurfaceNormal);
DecalComp->SetWorldRotation(DecalRot); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?