# Node

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.

### Types of Nodes:

#### **Tasks**:

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.

<figure><img src="/files/zNhXkUDbN2lQTYjua92r" alt="" width="375"><figcaption><p>Task node</p></figcaption></figure>

#### **Sequences**:

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.

<figure><img src="/files/Tq85ppCGl4AiCL5872m4" alt="" width="563"><figcaption></figcaption></figure>

#### **Selectors**:

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.

<figure><img src="/files/eUsBEZrmkW1O8VLTVjh4" alt=""><figcaption></figcaption></figure>

#### **Parallels**:

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.

<figure><img src="/files/9tbMYgYR5tg1bb4poTyE" alt=""><figcaption></figcaption></figure>

#### How It Works:

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://renownedgames.gitbook.io/ai-tree/basic/behaviour-tree/node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
