AAIController::SetPerceptionComponent
#include "AIController.h"
Access: public
Description
Assigns an existing UAIPerceptionComponent to this controller, replacing the default one. Intended for initialization and setup, not runtime hot-swapping.
Caveats & Gotchas
- • Takes a reference, not a pointer — the component must already exist and be valid at the call site. The controller does not create or own the component; you are responsible for its lifetime.
- • Calling this after perception has already started does not migrate accumulated percept data to the new component. Existing OnTargetPerceptionUpdated bindings on the old component will stop firing after the swap.
Signature
void SetPerceptionComponent(UAIPerceptionComponent& InPerceptionComponent) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InPerceptionComponent | UAIPerceptionComponent& | The perception component to assign to this controller. | — |
Return Type
void Example
Assign a manually created perception component in the constructor C++
AMyAIController::AMyAIController()
{
UAIPerceptionComponent* PC = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("PerceptionComp"));
SetPerceptionComponent(*PC);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?