AAIController::K2_SetFocus
#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
Track a player as AI focus target C++
void AMyAIController::SetTargetActor(AActor* Target)
{
TargetActor = Target;
K2_SetFocus(Target);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?