APawn::AIControllerClass
#include "GameFramework/Pawn.h"
Access: public
Specifiers: UPROPERTYEditAnywhereBlueprintReadWrite
Description
The controller class to instantiate when this pawn is automatically possessed by AI. Set this to your custom AIController subclass in the pawn's constructor to give the NPC its own decision-making logic.
Caveats & Gotchas
- • Setting this to a PlayerController subclass is technically valid C++ but will cause undefined behaviour — only AIController or its subclasses should be used here.
- • Changing this property at runtime after the pawn is already possessed has no effect; the already-spawned controller continues to run. Call SpawnDefaultController() after updating the class if you need a new controller mid-play.
Signature
TSubclassOf<AController> AIControllerClass Examples
Assign a custom AI controller class at construction time
Blueprint
Assign a custom AI controller in the pawn constructor C++
AMyEnemy::AMyEnemy()
{
AIControllerClass = AMyEnemyAIController::StaticClass();
AutoPossessAI = EAutoPossessAI::PlacedInWorldOrSpawned;
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?