UKismetMathLibrary::FindRelativeLookAtRotation
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the local-space rotator (clamped to [-180, 180] per axis) that an object with StartTransform needs to face TargetLocation. Useful for aim offsets and procedural look-at animation.
Caveats & Gotchas
- • The result is in local (relative) space, not world space — passing it directly to SetActorRotation will produce incorrect results. Use it as an aim-offset delta on top of the base rotation.
- • Yaw is computed as azimuth relative to the StartTransform forward vector, so the output changes if the character's facing direction changes even if neither the object nor target has moved.
Signature
static ENGINE_API FRotator FindRelativeLookAtRotation(const FTransform& StartTransform, const FVector& TargetLocation); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| StartTransform | const FTransform& | The world transform of the observing object, including its current orientation. | — |
| TargetLocation | const FVector& | World position to look toward. | — |
Return Type
FRotator Example
Compute aim offset for a character looking at a target C++
FRotator AimOffset = UKismetMathLibrary::FindRelativeLookAtRotation(
GetActorTransform(),
TargetActor->GetActorLocation());
// Feed AimOffset.Pitch / AimOffset.Yaw into your AnimBlueprint aim-offset node Tags
Version History
Introduced in: 4.20
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?