AAIController::SetPawn
#include "AIController.h"
Access: public
Specifiers: virtualoverrideAIMODULE_API
Description
Called internally when the controlled pawn changes. Overridden in AAIController to update AI subsystems (perception, focus) when a new pawn is assigned.
Caveats & Gotchas
- • Do not call this directly to possess a pawn — use Possess() or OnPossess() instead. SetPawn() only updates the pointer; it does not handle game-state side effects of possession.
- • When InPawn is null (unpossession), AI logic controlled by BrainComponent may be stopped or paused depending on the bStopAILogicOnUnposses flag.
Signature
virtual void SetPawn(APawn* InPawn) override; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InPawn | APawn* | The pawn to assign to this controller, or null to clear the possessed pawn. | — |
Return Type
void Example
Override to cache a typed pawn reference C++
void AMyAIController::SetPawn(APawn* InPawn)
{
Super::SetPawn(InPawn);
MyPawn = Cast<AMyCharacter>(InPawn);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?