RealDocs

UKismetMathLibrary::MakeRotFromZX

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPure

Description

Builds a rotator with Z fixed as the up axis and X adjusted for orthogonality, computing Y as the cross product. Commonly used for aligning objects to a surface normal while keeping a forward-direction hint.

Caveats & Gotchas

  • Z is preserved exactly; X may be modified. If you need X preserved instead, use MakeRotFromXZ.
  • This is the typical choice for surface-aligned objects (decals, grass) where the surface normal (Z) is critical and the facing direction (X) is secondary.

Signature

static UE_INL_API FRotator MakeRotFromZX(const FVector& Z, const FVector& X);

Parameters

Name Type Description Default
Z const FVector& Primary (fixed) up axis.
X const FVector& Secondary forward axis, adjusted for orthogonality.

Return Type

FRotator

Example

Place a decal flush to a wall with a facing hint C++
FVector WallNormal = HitResult.ImpactNormal;
FVector ForwardHint = CameraComponent->GetForwardVector();
FRotator DecalRot = UKismetMathLibrary::MakeRotFromZX(WallNormal, ForwardHint);
DecalComp->SetWorldRotation(DecalRot);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.