All Projects → yanevyuk → turgys-behavior-tree-plugin

yanevyuk / turgys-behavior-tree-plugin

Licence: Apache-2.0 license
No description, website, or topics provided.

Programming Languages

GDScript
375 projects

Turgy's Behavior Tree Plugin

A Behavior Tree implementation for Godot with a graphical interface.

Graph Editor Preview

Installation

  1. Install this plugin through the Asset Library in godot or paste the contents of this repository to your projects folder.

  2. Activate the plugin in Godot through the project settings

Instructions

  1. Add a BehaviorTree node and a Blackboard node to your scene.

  2. Set the BehaviorTree Folder of BehaviorTree to the folder where you want to keep your action and condition scripts.

  3. Likewise, set the logicRoot to the main node that will be affected.

  4. Set the blackboard to the blackboard object you have just created.

  5. From any script, call the "_tick" function of the BehaviorTree object.

    1. You can call it from _process or _physics_process to continuously run it. If this errors you can instead:

    2. Call it only once but add a repeat node right after the root node in the graph editor.

New Nodes

This plugin adds two new nodes which you need to use, it also adds other nodes that are generated by the main nodes hence you don't need to use them.

BehaviorTree

This is the core node of the plugin. Add this node to any node you desire. There are several variables in the inspector window.

BehaviorTree Folder: This is the folder where you will be saving your action and condition scripts. You might want to create a new folder

logicRoot: The logicRoot is the node that will be directly affected by the behavior tree. Generally you want this to be for example the npc's root node.

Blackboard: You must create a blackboard object in the same place as the behavior tree and link it to the variable.

The rest of the variables are there for functionality and you should ignore them.

Blackboard

The blackboard is transferred to all action and condition nodes. It is a dictionary meant to be a memory. Methods:

_add(key: String, val): Adds a new key to the dictionary, aborts if the key already exists

_put(key: String, val): Puts the new pair into the dictionary. If the key already exists, the value is overridden.

_remove_key(key: String): Removes the key from the dictionary.

_has_key(key: String): Returns true if the blackboard has the key.

_get(key: String): Returns the value associated with the key.

_get_key(val): Returns the key associated with the object.

Graph Editor

Graph Editor Preview

When you select any behavior tree, a graph editor dock appears next to Inspector and Node docks. In this screen, you can create your behavior tree.

You can press add or right click anywhere to add new graph nodes.

Ctrl+S saves the graph automatically, but it is safer to use the save button.

Root

All your behavior trees should start with this node.

Composites

Composite nodes can have more than one child

Sequence

The Sequence node ticks its children in order returning at the first FAILURE or ERR_BUSY, in which case it returns the encountered value.

Selector

The Selector node ticks its children in order returning at the first OK, in which case it returns OK. If all of its children return FAILURE, it also returns FAILURE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].