Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 5.63 KB

Home.md

File metadata and controls

74 lines (55 loc) · 5.63 KB

Welcome to the addons-btree wiki!

Warning : is this the best way ? No. Nothing is perfect. This plugin was designed for my own game, I wanted to make it simple and threw programming's best practices out the window. It may have some flaws, but for my case it was perfect. Try it for 15 minutes and if you don't think it fits your use case, no harm done, don't waste your time. Otherwise, I hope you enjoy the plugin!

1. Installation

Clone or download the addons folder and add it in your project.
OR
Download the plugin via the Godot Asset Library:

files

Then activate the plugin in your Project Settings.

setting

2. Concept

  • It is a behavior tree just like any other, no magic here, if you need to learn the concept, a quick google search will get you a long way.
  • The addon works with only a single script, you can however combine multiple BTree's in one parent. For example, you can separate your animation tree from your logic tree.

mtree

3. How to use BTREE

  • You can add BTREE as a child to any node. You must add a script to the BTree or the plugin will error!

create

  • Select the BTREE node and switch to the BTree Editor (BTEditor) window in the top menu.

5

  • You will need a node to connect to the root or it will not run.
  • To create a task / leaf node, you will need to make a function that follows this naming scheme: task_<methodname>(task). For example, a function that prints "hello world" can have the name task_printhelloworld(task).
  • The function must also have the argument task. This argument is used for flow control.
  • You can call functions on this argument. You can call succeed() to complete the task on success or failed() to complete on failure. The task status keeps running if you do not call anything, that means in the next tick it will be called again until you call succeed() or failed(). To determine if a task is initialized or not you can call is_init() in the control flow. If it returns true then the node is initialized, this is useful for a task that requires something to be initialized before running, for example, computing a path.

6

7

  • You can also pass your owns arguments to the task from the Tree Editor. This is for example useful when creating some kind of dialogue system for NPCs or to play an animation.

8

9

  • You can look up the rest of the node behavior by hovering your mouse which displays a tool tip you can use. The is also a help button that explains some basic controls like copying, deleting and saving nodes etc..

4. Debugger

  • You can visualize the current running BTree instance in your game by clicking the debug button, your game must be running or debugger will not show anything.
  • Currently you can only see the status but if you need anything more advanced or fancy, feel free to create an issue. d1 d2
  • The Debugger will currently does not work on mobile, only local desktop machine is supported.
  • You can pause a BTree while debugging by pressing pause.
  • You can step a BTree while it is paused by pressing and holding the step button.
  • To perform a hot reload go to the BTEditor while your project is running, perform your changes and afterwards after press save or CTRL + S, this will update your whole project, not only the running tree but also the same tree after it gets instanced.

5. Tutorial

  • The tutorial is credited to this Youtube channel Vic Ben
  • This is a great tutorial on how to use the plugins Video Link
  • Again I have to thank Vic Ben for making these tutorial videos.

Updates

This is here to keep track of changes from https://github.com/fian46/addons-btree

  • 9/7/2021
    • Refactored many editor nodes to inherit from a single class to make it easier to modify more general things.
    • Added ability to rename nodes with undo-redo functionality
    • Fixed issue with changing tabs and BTree not saving
    • Modified some nodes to stop using call_deferred since it was causing loading after editor was closed and reopened to not populate fields

Planned

  • Generalize wait and random_wait to inherit from a common class.
  • Generalize repeat and random_repeat to inherit from a common class.
  • A way to have "branches" of trees that can be added to a tree. When added it would run everything inside inner tree. Making it easier to organize and share behaviors.

Other

  • Feel free to contribute if you would like!
  • I will probably be adding features as I need them for my own game.