CAIUMODULE
Overview
The CAIUMODULE provides an AI controller and a set of Behavior Tree task nodes for NPC behavior. It wraps Unreal Engine’s AAIController with perception setup (sight), team attitude, blackboard management, and fight-state broadcasting. Task nodes cover movement, attack, automation, navigation recovery and idle waiting.
Depends on CCOREUMODULE, AIModule, NavigationSystem, GameplayTasks.
| Functionalities | Overview |
|---|---|
| AI Controller | ACAIController — AI controller with sight perception, behavior tree execution, team attitude and fight-state management |
| Data | FCAIStruct — DataTable row configuring perception radius, vision angle, forget delay and behavior tree reference |
| Task Nodes | 8 custom UBTTaskNode subclasses for attack, movement, automation, navigation recovery and waiting |
| Blueprint | UCAIBPLibrary — Blueprint function library (currently empty) |
ACAIController
ACAIController extends AAIController with UCrowdFollowingComponent for crowd avoidance. On possession it:
- Reads perception configuration from
FCAIStructvia the pawn’sUCInitializerComponent_. - Creates a
UAIPerceptionComponentwithUAISenseConfig_Sight(enemies only) if sight is enabled. - Adjusts
ARecastNavMesh::AgentRadiusto match the sight radius. - Runs the referenced
UBehaviorTree. - Sets the
automationKeyblackboard key if the pawn has a non-emptyUCAutomationComponent_.
Perception callbacks update the hostileActorKey blackboard key and broadcast fight reason changes to ACPlayerController.
FCAIStruct
| Property | Type | Default | Description |
|---|---|---|---|
| behaviorTree | UBehaviorTree* |
nullptr | Behavior tree to run on possession |
| enableSight | bool | true | Enable sight perception |
| sightRadius | float | 3000 | Detection radius |
| loseSightRadius | float | 5000 | Radius at which a detected actor is lost |
| peripheralVisionAngleDegrees | float | 66 | Half-angle of the vision cone |
| forgetAfterInSec | float | 5 | Time before a detected actor is forgotten |