AI Framework {{ currentPage ? currentPage.title : "" }}

10.1 AIController

Inside the pawn’s (or Character’s) blueprint you can set the actual class of it’s default controller to be spawned. To use ACF’s AI System you have to set it as a Subclass of ACFAIController. 

In the selected controller you then have to set the Behavioral Three, responsible of the realtime decisions of the controlled AI. In ACF there are two differents BehavoralThree for combat characters and NPCs. For every AI you’ll also have to set the CombatTeam as described in chapter 6.2. 

AIController also exposes the TeleportHome and GoBackHome functions which basically are triggered once the controlled pawn goes over the set distance from Home. 

But what is “home”? 

Home is defined only for AI groups. For companions (AI that have a lead, usually one of the Players) home location is actually the position of the Lead Actor (the Owning Player). For Ai groups spawned by an AIGroupSpawner, the location of the group will be the actual home location. 

BoundToHome functionality will make your AI come back to the home position once it's distance from that location is over MaxDistancefromHome. Similarly Teleport Home will teleport your AI in a random place in a TeleportHomeNearRadius from Home Location once it's distance overcomes TeleportHomeTriggerDistance.

10.1.1 AI States

In ACF AIs can be in 3 different states:

  • Patrol: If you add a USplineComponent in the AI Pawn or on the AIGroupSpawner, once the AI will be in Pathrol state, it will use that spline to actual define is Pathrol path. If the spline is an open loop, once reached the end of the spline the Ai will start following the path backward.

  • Combat: The AI is fighting against is actual target

  • GoHome: The AI is actually trying to reach his Home Location

For each state you can set the desired locomotion state that the character should maintain while staying in this state.

10.1.1 AI Aggressivity

If IsAggressive is set to true the possessed AI will attack everytime an enemy entity is detected. If only ShouldReactOnHit is selected, the AI will only "return to fire" once he, or a member of his group, gots hit. 

10.2 AICombat Behavior

Combat behavior Component is the component that manages how his controlled AI behaves in Combat. There are 2 different combat behavior types: melee and ranged. Every AI can be melee, ranged or both, switching behavior considering the actual situation.

AI can fight Unarmed or with a weapon, if your AI needs one or more weapon to fight, you have to check the NeedsWeaponTag and you have to provide to the component the actions to trigger to actually equip the desired weapon. Please notice that those action needs to be implemented in AnimBP as described in Chapter of Anims. During combat AIs can switch between multiple states, in particular: 

- Melee Attacks: AI will perform a Set of attacks actions for a total number of triggers that is between MinMeleeComboAttacks and MaxMeleeComboAttacks, then will try to go to post attack. This is supposed to be triggered once the AI is in Melee Range (below a certain distance)

- Melee PostAttacks: AI will perform a set of configurable actions, a different set from Melee Attacks, useful

to add variations in combat. In example this is used for ai to permorm a TauntAction. 

- Study Target: AI will move around target inside a circle of the distance define in CombatState Config. 

- Ranged Attacks: AI will perform a series of action that tryes to hit the target while keeping a distanceas defined int the CombatStates Config map. Usefull for bow shots/crossbow/speels projectiles etc. 

- Flee: state in which the AI tries to increase the distance from his target. 

CombatStateConfig is actually the map that describes the CombatStates this AI can go throught, the ideal distance in which each state is triggered and chance express in a 0-100 range. 

  

10.3 Threath Manager

Threat Manager component is used to setup the threat management of the Possessed AI. For every class you can define the default threat generated on perception (on sight, on heard) and the multiplier applied to the damage to calculate the threat generated by all the actors of that subclass. 

10.4 Groups & Companions

To work with AI groups you have to refer with ACFGroupComponent. In the component you can setup the array of AIs that will be spawnedtand their relative position from the Group. To actually spawn those AI you'll need to call SpawnGroup that can be called multiple times untlil MaxSimultaneousAgents is reached.

ACFAIGroupSpawners are pawns that owns an ACFGroupSpawnerComponent instance. They can be placed in the world and can be used to define Patrol path of the AI group and to eventually override agents Perception. If OverrideAgentPerception is set to true, all the perception of single AIs will be disabled and a single perception for the entire group will be used (higher performance, worst AI behavior accuracy). The AIGroupSpawner of the group position will be considered the Home of the agents and AI of the same group helps each other in battle. 

ACFCompanionsComponent is a specification of ACFGroupComponent to handle AIs that are in the same group of the player. Player will be considered their lead and player position will be considered their home. All AI agents can receive and execute commands. 

10.5 AI Commands

Ai Commands are a basic command pattern implementation to let AI implement custom actions. In depth tutorial: https://www.youtube.com/watch?v=xEr1nRDLB8c

{{{ content }}}