Enemy behavior can be customized and controlled by manipulating data in two main blueprint assets, the SM_Behavior blueprint state and the behavior tree. Both are used in combination to allow for highly customizable AI behavior.
Behavior State
A BehaviorState, derived from the BP_StateMachine class, defines what a behavior state does when entering a state, ending a state, & can manage the transition between a finite number of states.
The base behavior state is the SM_Behavior, derived from that class is the SM_Humanoid_CombatBehavior which is the behavior class used for all the default included enemies in the framework. Derived classes of SM_Humanoid_CombatBehavior can be created in order to manipulate data that controls the enemy behavior.
Behavior related properties can be modified using this blueprint. Properties such as:
Attack Distance
Attack Change
Enemy Aggression - controls how often the enemy attacks
Enemy Aggression Multiplier - can be used for custom aggression multiplier if the default isn’t enough
Strafing Behavior Ranges
Following Behavior Ranges
Behavior related Movement Speed
Turning distances
Return To Post distances
Retaliation data
Healing Behavior data
Enemy Defense data
This data will allow for extensive customization of the enemy AI behavior without the need to write any logic or code. In order to customize this data you will need to create a child class of SM_Humanoid_CombatBehavior and select this behavior data asset in the Enemy Info Data Asset under the “Behavior” section.
Behavior Tree
The enemy combat behavior tree is used to define the specific tasks performed by the enemy AI. For example, when in the attacking state various tasks can be added to the behavior tree to customize what the enemy does while in this state.
Behavior Tasks
Tasks such as performing an attack or other action can be added to the behavior tree. If you want the enemy to perform specific types of attacks or add a custom type of attack, this can be done by adding a task to the behavior tree and performing blackboard based condition checks such as a distance check or chance based condition.
Attack Distance
The behavior Tree is where you adjust things such as Enemy Attack Distance settings, such as what distance is considered close, medium, and far range attacks for the enemy and which tasks to perform in these attack ranges. But also remember that there is also an attack behavior distance setting in the enemy SM_Humanoid_CombatBehavior as well.
Movement Speed
Enemy movement speed can also be set using a task in the behavior tree. In addition to that, behavior specific movement speed options are available in the SM_Humanoid_CombatBehavior. But the movement speed task in the behavior tree will take priority over the setting in the combat behavior blueprint.