A BehaviorTree
chooses a behavior to be exhibited by an AI-controlled unit at any given moment in time. Behavior Trees are relatively simple to construct, but there is a lot of setting up to do to get one running. You also have to be familiar with the components available for constructing your Behavior Tree to do so effectively.
A Behavior Tree is extremely useful for defining NPC behavior that is more varied than simply moving towards an opponent (as shown in the previous recipe with AIMoveTo
).
The process of setting up a Behavior Tree to control a character is fairly complicated. The first thing we need is a Blueprint of a Character
class derivative to control. We then need to create a custom AI Controller object that will run our Behavior Tree to control our Melee attacker character. The AIController
class inside our Blueprint will run our Behavior Tree.
The Behavior Tree itself contains a very important data structure called a Blackboard...