UKismetMathLibrary::FindLookAtRotation
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the rotation needed for an object at Start to face the Target position in world space. Only Pitch and Yaw are computed; Roll is always zero in the result.
Caveats & Gotchas
- • Roll is always 0 in the returned rotator — if you need a roll component, you must add it manually after calling this function.
- • When Start and Target are the same point the function returns a zero rotator rather than asserting, so check for coincident positions if that case should be an error in your logic.
- • The result is in world space. To drive an aim-offset or socket that lives in local space, combine the result with the owning component's inverse rotation using NormalizedDeltaRotator.
Signature
static UE_INL_API FRotator FindLookAtRotation(const FVector& Start, const FVector& Target); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Start | const FVector& | The world position of the observing object. | — |
| Target | const FVector& | The world position to look toward. | — |
Return Type
FRotator Example
Face a target actor C++
FRotator LookAt = UKismetMathLibrary::FindLookAtRotation(
GetActorLocation(),
TargetActor->GetActorLocation());
SetActorRotation(LookAt); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?