RealDocs

AAIController::K2_SetFocus

function AIModule Blueprint Since 4.0
#include "AIController.h"
Access: public Specifiers: UFUNCTIONBlueprintCallable

Description

Sets this controller's focus to a specific actor so the pawn continuously rotates toward it each tick. Exposed to Blueprint as 'SetFocus'.

Caveats & Gotchas

  • Stores a weak pointer to the actor internally. If the actor is destroyed, the focus becomes invalid and GetFocalPoint returns FAISystem::InvalidLocation — but K2_ClearFocus is not called automatically. Clear focus explicitly on actor death to avoid stale state.
  • Operates at EAIFocusPriority::Gameplay. The movement system uses EAIFocusPriority::Move for path-following rotation; focus set here will override rotational intent only when Move-priority focus is absent.

Signature

void K2_SetFocus(AActor* NewFocus)

Parameters

Name Type Description Default
NewFocus AActor* The actor to continuously track as the focus target.

Return Type

void

Examples

Set AI focus to an overlapping actor on begin overlap Blueprint
Event Actor Begin Overlap Other Overlap Info Other Overlap Info Other Actor Cast To AAIController Object Cast Failed As AI Controller As AI Controller K2 Set Focus Target is AI Controller Target New Focus Get Controller Target is Pawn Return Value Return Value
Edit Blueprint graph Set AI focus to an overlapping actor on begin overlap
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Track a player as AI focus target C++
void AMyAIController::SetTargetActor(AActor* Target)
{
	TargetActor = Target;
	K2_SetFocus(Target);
}

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.