RealDocs

AAIController::GetAIPerceptionComponent

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

Description

Returns the UAIPerceptionComponent attached to this controller. Use this to query what the AI currently senses — actors it has seen, heard, or detected through damage.

Caveats & Gotchas

  • Returns null if no UAIPerceptionComponent has been added to the controller. The component is optional — basic AI controllers using only NavMesh movement do not need it.
  • This is a non-const getter (a const overload also exists but is not BlueprintPure). The non-const version is what Blueprint calls; be aware you can modify the component through the returned pointer.

Signature

UAIPerceptionComponent* GetAIPerceptionComponent()

Return Type

UAIPerceptionComponent*

Examples

Retrieve the perception component and query currently sensed actors Blueprint
Event BeginPlay Cast To AAIController Object Cast Failed As AI Controller As AI Controller Get AI Perception Component Target is AI Controller Target Return Value Get Currently Perceived Actors Target is AI Perception Component Target Sense To Use Actors Get Controller Target is Pawn Return Value Return Value
Edit Blueprint graph Retrieve the perception component and query currently sensed actors
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Query currently sensed actors C++
UAIPerceptionComponent* Perception = GetAIPerceptionComponent();
if (Perception)
{
	TArray<AActor*> SensedActors;
	Perception->GetCurrentlyPerceivedActors(UAISense_Sight::StaticClass(), SensedActors);
	for (AActor* Actor : SensedActors)
	{
		// React to each seen actor
	}
}

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.