UKismetMathLibrary::MakeRotFromXY
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Builds a rotator from two axes: X is treated as the primary (fixed) forward axis, and Y is adjusted to be orthogonal to X. Z is computed as the cross product. Inputs need not be normalized.
Caveats & Gotchas
- • X is guaranteed to be preserved exactly (after normalization); Y may be rotated in the XY plane to enforce orthogonality, so the returned rotator's Y axis may not match the input Y axis exactly.
- • If X and Y are parallel or anti-parallel the result is degenerate — the engine does not assert, so the output will be numerically unstable.
Signature
static UE_INL_API FRotator MakeRotFromXY(const FVector& X, const FVector& Y); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| X | const FVector& | Primary (fixed) forward axis. Will not be modified. | — |
| Y | const FVector& | Secondary right axis, adjusted minimally to enforce orthogonality. | — |
Return Type
FRotator Example
Orient a weapon to face forward with a known up hint C++
FVector Forward = (Target - Source).GetSafeNormal();
FVector Right = FVector::CrossProduct(FVector::UpVector, Forward).GetSafeNormal();
FRotator WeaponRot = UKismetMathLibrary::MakeRotFromXY(Forward, Right); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?