AAIController::GetAIPerceptionComponent
#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
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
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?