Documentation for AACFAIController
Overview
AACFAIController is an integral part of the ACF framework, responsible for controlling individual AI agents. It integrates with Unreal Engine’s behavior tree and blackboard systems to provide advanced AI functionalities such as state management, perception handling, threat evaluation, and dynamic combat behavior.
AACFAIController
Description
The AACFAIController is designed to control AI characters within the ACF framework. It utilizes behavior trees, blackboard assets, and perception systems to enable dynamic AI responses in combat and non-combat scenarios. It also interfaces with ACF-specific components like targeting and threat management to create responsive and intelligent AI agents.
Features
Full integration with Unreal Engine’s AI behavior tree and blackboard systems.
Perception handling with customizable responses to sight, sound, and other stimuli.
Advanced threat evaluation and prioritization using UACFThreatManagerComponent.
State-based AI with smooth transitions between behaviors.
Group coordination through UACFGroupAIComponent.
Key Properties
BehaviorTreeComponent: Manages the execution of the assigned behavior tree.
BlackboardComponent: Handles key-value pairs used to control AI behavior.
CommandsManagerComp: Executes and manages commands issued to the AI.
TargetingComponent: Manages the AI’s targeting logic.
ThreatComponent: Evaluates threats and assigns priorities to potential targets.
CharacterOwned: Reference to the AI character being controlled.
GroupOwner: Reference to the owning UACFGroupAIComponent.
DefaultState: Specifies the default state for the AI.
HomeLocation: Tracks the AI’s home location for return behaviors.
Key Methods
OnPossess(APawn possPawn): Initializes the AI character and behavior tree when possessing a pawn.
OnUnPossess(): Cleans up references and detaches components when unpossessing a pawn.
SetTarget(AActor inTarget): Assigns a target to the AI and updates its state accordingly.
RequestAnotherTarget(): Finds a new target for the AI based on threat prioritization.
SetCurrentAIStateBK(EAIState aiState): Updates the AI’s state and triggers associated behaviors.
UpdateCombatLocomotion(): Adjusts locomotion settings based on the combat state.
TeleportNearLead(): Teleports the AI close to its group leader.
SetPatrolPath(AACFPatrolPath inPatrol, bool forcePathFollowing): Sets a patrol path for the AI to follow.
SetGroupOwner(UACFGroupAIComponent group, int32 groupIndex, bool disablePerception, bool bOverrideTeam): Assigns the AI to a group and adjusts settings.
Events
OnAIStateChanged: Broadcasts whenever the AI’s state changes.
OnAICombatStateChanged: Broadcasts whenever the AI’s combat state changes.
Example Usage
// Example: Setting up an AI controller for combat
AACFAIController* AIController = Cast<AACFAIController>(AICharacter->GetController());
if (AIController) {
AIController->SetCurrentAIStateBK(EAIState::EBattle);
AIController->SetTarget(SomeTargetActor);
}
Notes
Ensure that all dependencies, such as AACFCharacter, UACFGroupAIComponent, and UACFThreatManagerComponent, are implemented correctly.
The AACFAIController works seamlessly with ACF’s group and companion systems, making it ideal for both individual and group-based AI scenarios.
This document provides an overview of the AACFAIController class, highlighting its features, properties, methods, and integration with the ACF framework. Use it as a reference to implement and extend AI behavior in your projects.