RealDocs

AAIController::GetPerceptionComponent

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

Description

Returns the UAIPerceptionComponent attached to this controller, satisfying the IAIPerceptionListenerInterface contract. Internally delegates to GetAIPerceptionComponent().

Caveats & Gotchas

  • From C++, prefer calling GetAIPerceptionComponent() directly — it is a UFUNCTION(BlueprintPure) non-virtual inline and avoids the vtable dispatch overhead. GetPerceptionComponent() exists to satisfy the interface contract.
  • Returns null if no perception component was added during construction. UAIPerceptionComponent is not created automatically by the base AAIController — you must add it in your subclass constructor or via SetPerceptionComponent.

Signature

virtual UAIPerceptionComponent* GetPerceptionComponent() override

Return Type

UAIPerceptionComponent*

Example

Access perception via the interface pointer C++
IAIPerceptionListenerInterface* Listener = Cast<IAIPerceptionListenerInterface>(MyController);
if (Listener)
{
	UAIPerceptionComponent* PC = Listener->GetPerceptionComponent();
	// Equivalent to MyController->PerceptionComponent
}

Tags

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.