Documentation

Learn how to use NodeCanvas

Download PDF Version

Creating Custom BT Nodes

While the recommended way of working with NodeCanvas is to create Tasks and use them instead so that the design can be modular, you are also able to create your own custom Behaviour Tree nodes, either Composites, Decorators or Leafs. In either case, you have to derive from the respective base type, override the required methods and use the inherited properties.

Following is a template with most methods that you can optionally override and are common to all three behaviour tree node types.

Here are some important  common inherited properties:

Status status
The current status of the node. You can also  use this to temporary store a status as you’ll see later on.

Component graphAgent
The executive agent of the Behaviour Tree

IBlackboard graphBlackboard
The blackboard of the Beheaviour Tree

List<Connection> outConnections
In NodeCanvas, connections are object by themselves. You get to access child nodes through their connections. Connections also have an Execute method which returns a Status as you will see later on.

Creating a Leaf Node

Behaviour Tree leaf nodes, have no child nodes. To create a leaf node derive from BTNode. Following is a simple delay Behaviour Tree action node.

Again, it is very recommended to use the existing Action and Condition Behaviour Tree nodes and create Action and Condition Tasks respectively to use with them instead of creating leaf action/condition nodes this way.

Creating a Decorator Node

To create a Decorator you should derive from BTDecorator base type. Decorator nodes can only have one child node. You access that child through the connection object. Here is an Inverter Decorator for example.

You get to access and execute the decorated child node through the connection object. In NodeCanvas, connections are objects by themselves and they also have an Execute method that returns a Status.

Creating a Composite Node

To create a Composite, you derive from BTComposite base type. Composite nodes can have any number of connected child nodes. Similar to decorators, you get to access and execute child nodes through the connections. Here is an example of a simple sequencer.

That’s it. Remember that double clicking on a node, opens it up in your IDE.

Yes No Suggest edit
5 of 5 users found this section helpful
Suggest Edit