Node
Basic info about task nodes in AI Tree
Last updated
Basic info about task nodes in AI Tree
Last updated
Nodes are the fundamental building blocks that define the behavior logic of characters or NPCs. Nodes can perform various functions and are the foundation for creating complex hierarchies of behavior.
Tasks represent nodes that perform specific actions or commands. For example, an NPC might execute a movement task, an attack task, a rest task, or an interaction task. Tasks can be one-time or recurring, depending on their logic.
Sequences are nodes that execute child nodes sequentially. If any child node fails to execute (e.g., if a task returns a failure status), the entire sequence is considered a failure.
Selector nodes allow for the selection of one among several child nodes for execution. They operate on a "first success" principle—if one of the child nodes returns success, the execution stops, and the remaining child nodes are not checked.
Parallel nodes can run multiple child nodes simultaneously. They allow, for example, an NPC to move and attack at the same time, waiting for the completion of all child tasks.
Nodes are organized in a hierarchical structure, where the root node represents the overall behavior of the NPC, and child nodes define specific actions and conditions. This hierarchy enables developers to visually design and manage NPC behavior, providing flexibility and convenience in creating complex behavior patterns.
For example, a behavior tree might contain a sequence that checks if the NPC is in combat (a decorator) and then executes an attack task or retreats if health is low (a task).
In this way, nodes (tasks) in behavior trees provide flexibility and power in managing NPC behavior, allowing developers to create more complex and interesting gameplay scenarios.