Understanding decorators
Decorators provide a way to add additional functionality or conditions to the execution of a portion of a behavior tree. As you already know from previous chapters, decorators are attached to either a composite or a task node and determine whether a branch in the tree (or even a single node) can be executed. By combining decorators with composite nodes, you can create behavior trees with prioritized behavior allowing for powerful logic capable of handling intricate scenarios. In Chapter 8, Setting Up a Behavior Tree, we used some built-in decorators but, in this section, I will give you more detailed information about creating your own custom decorators.
Explaining the BTAuxiliaryNode class
Both decorators and services inherit from the BTAuxiliaryNode
class, which will let you implement the following functions:
OnBecomeRelevant()
: This will be called when the auxiliary node – the one the decorator or service is attached to – becomes...