Leaf nodes have no children at all and they live by the end of a branch.
The Action Node will execute an Action Task assigned. The Action node will return Running until the Action Task is finished at which point it will return Success or Failure based on the Action Task assigned. NC comes with a variety of different Action Tasks to use.
The Condition Node will execute a Condition Task and return Success or Failure based on that Condition Task. NC comes with a variety of different Condition Tasks to use.
Composites work with multiple chid nodes and execute them in some order based on the composite functionality.
The Sequencer executes it’s child nodes in order from highest to lowest priority (left to right). It will return Failure as soon as any child returns Failure. It will return Success if all children return Success.
A Dynamic Sequencer will revaluate higher priority children Status changes. So if a higher priority child status returns Failure, the Sequencer will Interrupt the currently Running child and return Failure as well. This is extremely useful to create dynamic and immediate responses to higher priority status changes like for example conditions.
A Random Sequencer will shuffle its children on each reset and then start executing them in the new order.
The Selector executes it’s child nodes in order from highest to lowest priority (left to right). It will return Success as soon as any child returns Success. It will return Failure if all children return in Failure.
A Dynamic Selector will revaluate higher priority children Status changes. So it a higher priority child status returns Success, the Selector will interrupt the currently Running child and return Success as well. Like the sequencer, this is extremely useful to respond immediately on status changes of higher priority children like for example conditions.
A Random Sequencer will shuffle its children on each reset and then start executing them in the new order.
The Probability Selector will select and execute a child node based on it’s chance to be selected. If that selected child returns Succes, the Probability Selector will also return Success. If it returns Failure though, a new child will be picked. The Probability Selector will return Failure if no child returned Success, or may immediately return Failure if a ‘Failure Chance’ is introduced.
As soon as you connect a child node, a probability value will show up in the inspector for that child and the node information will read the final chances calculated based on all probability values and the direct failure chance.
Note: The probability values can be taken from blackboard variables to dynamically alter the probabilities.
The Priority Selector is similar to a normal Selector but will pick the order of child execution based on the priority each child has. As soon as you connect child nodes, Priority weights will show up which you can alter either directly or through Blackboard variables.
The Parallel will execute all it’s children simultaneously. It can be set to have the policy of a Sequencer or a Selector like so:
If set to First Failure, then as soon as any child returns Failure, the parallel will reset all current Running children and return Failure as well. Else it will return Success when all children have returned Success.
If set to First Success, then as soon as any child returns Success, the parallel will reset all current Running children and return Success as well. Else it will return Failure when all children have returned Failure.
The Flip Selector works like a normal Selector, but once a child node returns Success, it is moved to the end (right). As a result, previously Failed children will always be checked first and recently Successful children last.
The Switch node can switch either an Enum or an Integer value. Depending on what the current Enum or integer value is, it will execute the respective child node. If another child node was previously Running, it will be interrupted. Once you connect child nodes, you the connections will read the enum or integer values.
Decorators always have one child node. They usually give extra functionality to that child, filter it or modify it in some way.
Interruptor gets assigned a Condition Task. If the condition is or becomes true, the child node will be interrupted if Running and the Interruptor will return Failure. Otherwise, the Interruptor will return whatever the child node returns.
Note: The fact that the Interruptor can be assigned any condition, makes possible for interruptions to happen due to any reason.
Conditional will execute it’s child node only if the condition assigned is true and then it will return whatever the child node returns. It will return Failure if the condition is false but the child node is not already Running. So in other words, if the condition succeeds even for one frame, the child node will execute and not be interrupted even if the condition no longer holds true.
This node is extremely useful for creating state-like behaviours and switching between them.
Inverter will remap it’s child node’s Success and Failure return status, to the opposite. Success: When the child node is remapped to Success.
Repeater will repeat it’s child either a Number of Times, or Until it returns the specified status, or Forever.
Note: The times to repeat can be assigned from a blackboard variable to make this more dynamic.
Filters the access of its child node either a specific Number of Times or every specific amount of time (like a Cooldown). By default, this node will be treated as Inactive in regards to its parent node if it is filtered. Unchecking this option will instead return Failure.
Note: The number of times and the cooldown time values can be set to be taken from the Blackboard to make this node more dynamic.
Iterator will iterate a List taken from the Blackboard. On each iteration, the current iterated element will be saved on that same blackboard with the name provided and the child node will be executed.
The Iterator can optionally be set to terminate iteration as soon as the decorated node returns either Success or Failure. If no termination condition is set (NONE) or if the list is iterated and the termination condition is not met, then the Iterator will return whatever the last iteration child execution returned.
If Reset Index is checked, then the Iterator will reset the current iterated index to zero whenever it resets, else the index will remain unless it’s the last index of the list. Think of it as a ‘for each’.
The Timeout decorator will interrupt the child node Running if it is Running for more time than the one specified in seconds. Otherwise, it will return whatever the child node returns.
Wait Until will return Running until the assigned Condition Task becomes true. If the condition becomes false after the child has been ticked, it will not interrupt it. The condition is checked only when the child is not already Running.
The Optional Decorator executes the decorated child without taking into account its Success or Failure return status, thus making it optional to the parent node in regards to status expected.
Protects the decorated child from Running if another Guard with the same specified token is already guarding (Running) that token. Guarding is global for all of the Behaviour Trees running for the same agent.
When protected, it can be set to either return Failure or Running.
Override Agent will set another Agent for the rest of the Behaviour Tree from its point and on from the game object directly selected or taken from a Blackboard variable. What this means is that every node underneath this decorator will now be Ticked for that new agent. This Decorator is one of the ways that NodeCanvas allows you to control more than one agents from a single “master” Behaviour Tree, or to dynamically change the agent.
Sub-Behaviours are references to other whole graphs, usually Behaviour Trees and are used for organization and behaviour modularity.
A SubTree is an entire other Behaviour Tree. The SubTree node will return whatever the assigned Behaviour Tree’s root node (“Start”) returns. The agent and the blackboard of the root Behaviour Tree will be passed down to the SubTree, thus all available blackboard variables will be the same and available to the SubTree as well.
Note: You can create a new SubTree out of a whole branch! To do this, right-click a composite node and select “Convert To SubTree”. This will create a new Behaviour Tree and a new SubTree Node. The selected node, as well as all of its children concurrently, will be moved to that new Behaviour Tree! This is extremely useful to organize the behaviours without knowing beforehand how that organization should be.
Nested FSM can be assigned an entire FSM. When executed, the FSM will Start. The NestedFSM node will return Running for as long as the FSM is running. You can specify one state of the FSM for Success and another for Failure. As soon as the nested FSM enters any of those states, the FSM will stop and this node will return Success or Failure accordingly. Otherwise, it will return Success when the nested FSM is finished somehow. The Agent and the Blackboard of this Behaviour Tree will be passed to the Nested FSM, thus all available variables of the root Behaviour Tree will also be the same and available to the Nested FSM.