RealDocs

AAIController::GetFocusActorForPriority

function AIModule Since 4.8
#include "AIController.h"
Access: public Specifiers: inlineconst

Description

Returns the actor set as the focus target at the specified priority slot, or nullptr if no actor focus has been assigned at that priority.

Caveats & Gotchas

  • Returns nullptr if the priority index is out of range — the priorities array may be empty until a focus has been set at least once. Do not use raw integer indices without validating the array size.
  • The underlying storage is a TWeakObjectPtr. A non-null return does not guarantee the actor is still alive; if the actor was destroyed after SetFocus was called, the pointer resolves to null.

Signature

inline AActor* GetFocusActorForPriority(EAIFocusPriority::Type InPriority) const { return FocusInformation.Priorities.IsValidIndex(InPriority) ? FocusInformation.Priorities[InPriority].Actor.Get() : nullptr; }

Parameters

Name Type Description Default
InPriority EAIFocusPriority::Type The focus priority slot to query (Default=0, Move=1, Gameplay=2).

Return Type

AActor*

Example

Read the Gameplay-priority focus actor C++
AActor* GameplayFocusActor = MyAIController->GetFocusActorForPriority(EAIFocusPriority::Gameplay);
if (IsValid(GameplayFocusActor))
{
	// AI is actively tracking this actor
}

Tags

Version History

Introduced in: 4.8

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.