Behaviours
Behaviours determine how enemies behave and react in the game world via a modular behaviour tree.
Overview
Enemy behaviours are defined through a Behaviour Tree that controls how the AI transitions between different 'states' such as Idle, Alerted and Target Interaction. The behaviour tree acts as the decision-making backbone, combining modular tasks into fluid and reactive enemy behaviour.
Each behaviour is built as a reusable subtree that can be plugged into the main tree, making it easy to extend or customise for new enemy types. By combining these trees, developers can create enemies with varied personalities and strategies without rewriting core logic.
Behaviour Tree Assets
Behaviour trees form the core of all AI decision-making processes within the Enemy AI - Toolkit. At the highest level is the BT_Enemy
behaviour tree graph. This contains different subgraphs, each representing a different 'state': Target Interaction, Alerted and Idle. Each of these states is represented by a separate behaviour tree graph. While the main BT_Enemy
graph decides which state to execute based on the current world state, as represented by the blackboard, the nested behaviours handle the active decision-making. The following table explains all behaviour tree graphs:
BT Enemy
Handles the highest level of decision-making. Decides which general state to execute.
BT Target
Handles concrete target interaction, such as movement towards the target and interaction with the combat system.
BT Alerted
Handles investigation logic. It is triggered when the AI loses a target. It lets the AI investigate the last known target area.
BT Idle
It handles the idle decision-making process. It is executed when there is no target and nothing to investigate. It handles waiting, roaming or patrolling based on the selected enemy's idle mode.
Blackboard - World State
All enemy behaviour is based on decision-making through behaviour tree graphs. However, behaviour trees base their decision-making on the current world state, which is represented by the Blackboard. A blackboard essentially acts as a data container. Generally, there is one for each instance of your enemy agent. The AI controller writes data into the blackboard while the behaviour trees read data from it in order to make decisions. The following table provides a brief overview of all the data listed in the blackboard:
Contains general data that is used troughout the entire behaviour tree collection. Used to manage high level info or often used data.
Self Actor
References the actor of the agent. Default in any blackboard.
Origin Location
Holds the origin location. Selected by the AI controller, when the enemy is started. Takes agents postion at moment of execution.
Target
Defines the actor currently selected as the enmies target.
Idle Mode
Defines what mode the enemy should try to execute while within idle state.
Alerted
Defines if the enemy is currently alerted. Example: No target but still needs to investigate environment.
Nodes
The Enemy AI - Toolkit comes with several custom behaviour graph nodes. These nodes are used to deploy custom behaviour tailored to this system's exact use cases directly into the behaviour tree graph. The table below provides a quick overview of all the newly added nodes:
Get Patrol Point
This allows you to reach the next patrol point along the selected patrol route.
Perform Attack
Performs a weighted attack, based from all attacks set in the enemy config.
Set Bool
Sets a bool within the world state. Can be attached to other nodes in the behaviour tree graph.
Mode Comparer
Compares the currently active mode with a custom value.
Last updated