Using Blackboards with Behavior Trees
To use a blackboard asset you’ve created with a behavior tree, you need to specify the asset in the root node of the behavior tree. You can see an example in ShooterGame, where the “Blackboard Asset” property (in the Details window when the Root node is selected) is set to BotBloackboard.
Once you’ve done that, there are a number of ways to use the data in the blackboard.
There are some native code Decorators which support blackboard entries directly:
-
Blackboard decorator: Allows you to do some basic tests on the property depending on the type of the entry. For example:
-
“Is Set”: For boolean entries, “Is Set” means the value is true. For Actors and other UObjects, it means the value is not “None” (NULL).
-
Numeric comparisons versus a constant value. I.E. <=, <, >, >=, == (Equals), != (Not Equal To).
-
These are valid for ints and floats. In addition, these are allowed for Enums and Native Enums (which only allow you to specify the enum values through a dropdown). However, it’s best (in most cases) to just use Equals/Not Equals for enums. If you want to support multiple values, use a Composite decorator to “OR” the valid values together.
-
For Strings and Names, “Is Equal To”, “Is Not Equal To”, “Contains” and “Not Contains” are all supported.
-
Compare BBEntries decorator: Compares two separate entries on the blackboard to each other.
-
Composite decorator: These nodes can combine multiple Blackboard and Compare BB Entries nodes. (They can also compare blueprint decorators, but that doesn’t assist in using blackboard entries.)
In addition to these decorators, we plan on providing native support for blackboard context override soon.
Additionally, you can get and set the values of blackboard entries through either code (C++) or blueprints for any type of node you need. See information above about how to set or get values yourself through C++ or blueprints.