UKismetMathLibrary::MakeRotFromX
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Builds a rotator whose forward axis aligns with the given vector. Y and Z axes are chosen to be orthonormal but are otherwise arbitrary.
Caveats & Gotchas
- • Because only the X axis is constrained, the Roll component is underdetermined — the engine picks an arbitrary roll that may not match expectations, especially for camera or character orientation.
- • Passing a zero vector produces a degenerate result without assertion; always ensure the input is non-zero.
Signature
static UE_INL_API FRotator MakeRotFromX(const FVector& X); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| X | const FVector& | The desired forward (X) axis direction. Does not need to be normalized. | — |
Return Type
FRotator Example
Orient an arrow component toward a target C++
FVector Dir = (Target->GetActorLocation() - GetActorLocation()).GetSafeNormal();
FRotator Rot = UKismetMathLibrary::MakeRotFromX(Dir);
ArrowComp->SetWorldRotation(Rot); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?