Use Behavior Tree in Unity
In the easiest way, bring everyone to know and use the behavior tree, this series is updated for a long time, I hope everyone likes it!
Your support is my motivation for writing.
table of Contents:
1. Make the behavior tree parallel Parallel nodes
In the previous section, we knew and understood the Sequence and Selector in the combined node
In this section we take a look at other commonly used combination nodes.
1. Make the behavior tree parallel Parallel nodes
Establish the following behavior tree:
Analysis: All nodes under Parallel are executed at the beginning of the behavior tree, output A, and the object is disabled, but the wait is not executed successfully.
So parllel has the following characteristics
- Parallel all its children
- All nodes succeed, return success (if any child node fails, fail)
- If any child node is running, it must be in running
You can try the following examples to integrate the two kinds of combination nodes learned before:
Under the parallel node, the sequence of output A to find objects and wait for output B is executed in order.
2. Other combination nodes
name | legend | effect |
Parallel Selector | In parallel until success | |
Random Sequence | Randomly choose to execute the node until it fails | |
Random Selector | Randomly choose to execute from random nodes until successful | |
Untity Selector | Selector, select the branch with the largest weight to execute, and switch at any time (even if other nodes are running) |
Related Reading:
Unity's behavior tree from scratch (1)
Unity's behavior tree from scratch (2)