Skip to content
David Kamberský edited this page Aug 7, 2017 · 7 revisions

This page serves as a super quick summary of the main points of the Behavior system. The details of each part are detailed on their respective pages (check out the menu on the right).

For the purposes of this tutorial we'll assume you have an entity / creature you want to bring to life. If you don't, check out this tutorial to learn how to create one.

Assigning a Behavior to an Entity

To specify the behavior tree your entity will use, go into its .prefab file, and find (or create) the Behavior entry in the JSON.

The correct format is:

"Behavior" : {
    "tree" : "<module>:<behavior>"
}

Creating a Behavior

To create your own Behavior tree, which is what defines the behavior of an entity, go into the assets/behaviors folder of your module and create a new <name>.behavior file.

You can learn how to create your own Behavior here, but if you want to use a premade behavior, you can - e.g. engine:stray for the built-in stray behavior.

Nodes, Actions, Decorators

Nodes, implementing the BehaviorNode interface, are the building blocks of behavior trees. Every Node is denoted in the tree files using the name it returns through getName().

There are two main types of nodes:

  • the logic ones, detailed here
  • the 'action' ones, detailed here

For a general writeup about TreeNodes, see here.

Responding to outside changes

To see how a behavior tree can respond to events and changes in the entity, see here

GUI editor

F5 opens the GUI editor for behavior trees, which lets you inspect trees for individual entities as they execute, tweak parameters and assign new ones. For a more detailed look, see here.