RealDocs

UKismetAnimationLibrary::K2_LookAt

function AnimGraphRuntime Blueprint Since 4.0
#include "KismetAnimationLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Returns a copy of CurrentTransform rotated so a chosen local axis (LookAtVector) points toward TargetPosition, optionally constrained to a cone angle and twisted to align with an up vector.

Caveats & Gotchas

  • LookAtVector is a local-space axis on CurrentTransform (e.g. (1,0,0) for forward), not a world-space direction — passing a world-space vector produces an incorrect rotation.
  • ClampConeInDegree limits deviation from CurrentTransform's original orientation, so a small clamp value can prevent the bone from actually reaching TargetPosition even though the target is technically visible.
  • bUseUpVector adds a secondary twist solve; leaving it false is cheaper and sufficient when roll/twist around the look axis doesn't matter.

Signature

static FTransform K2_LookAt(const FTransform& CurrentTransform, const FVector& TargetPosition, FVector LookAtVector, bool bUseUpVector, FVector UpVector, float ClampConeInDegree)

Parameters

Name Type Description Default
CurrentTransform const FTransform& The input transform to reorient.
TargetPosition const FVector& The world position this transform should look at.
LookAtVector FVector The local-space vector on CurrentTransform that gets aligned toward TargetPosition.
bUseUpVector bool If true, also performs a twist rotation to align with UpVector. false
UpVector FVector The reference up direction used for twist alignment when bUseUpVector is true.
ClampConeInDegree float Limits how far the look-at rotation can deviate from the original orientation, in degrees.

Return Type

FTransform

Example

Point a bone transform at a target C++
const FTransform NewTransform = UKismetAnimationLibrary::K2_LookAt(
    HeadBoneTransform, TargetActor->GetActorLocation(),
    FVector::ForwardVector, false, FVector::UpVector, 45.0f);

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.