BeeTrees
A visual behavior tree editor for Visual Studio Code, based on the awesome work of tyridge77 and defaultio in BehaviorTree.
Installation Instructions
Download the extension from the Visual Studio Marketplace or Open VSX.
[!IMPORTANT]
Rojo 7.5 or later is required. It's the first version that adds support for setting ObjectValue.Value.
Features
Commands
All commands are in the Command Palette. Just type BeeTree to see a list of currently relevant ones.
| Command |
Action |
| New Behavior Tree |
Makes a new tree in a folder. Also in the Explorer context menu of a folder. |
| Open in Behavior Tree Editor |
Opens a default.project.json in the tree editor. Also in the Explorer context menu and the editor title bar. |
| Open Behavior Tree as Text |
Opens the tree file in the text editor. Also in the editor title bar. |
The following are only available when a tree editor is active. The node commands
apply to the selected node. They are also in the context menu of the canvas or
of a node.
| Command |
Action |
| Add Node |
Adds a node to the tree. |
| Show Help |
Shows or hides the help panel of the editor. |
| Zoom In / Zoom Out |
Changes the zoom of the canvas. |
| Show the Full Tree |
Moves and zooms the canvas to show all nodes. |
| Connect Node To... |
Makes a different node a child of the selected node. |
| Disconnect Node from Parent |
Removes the connection between the selected node and its parent. |
| Move Node... |
Moves the selected node to the next position that you click. |
| Resize Node... |
Changes the width and height of the selected node. |
| Duplicate Node |
Makes a copy of the selected node. A copy of a task node uses the same task file. |
| Duplicate Task with New File |
Makes a copy of the selected task node and of its task file. |
| Edit Task or Open Tree |
Opens the task file of a task node, or the tree of a tree node. |
| Delete Node |
Deletes the selected node. |
| Node Actions... |
Shows a list of the actions for the selected node. |
Accessibility Help (Alt+F1) |
Shows how to use the editor with only a keyboard. |
Configuration
| Setting |
Default |
Description |
beetrees.referenceViewport |
{ "width": 1600, "height": 900 } |
Node positions in the tree file are fractions of a workspace that is 20 times this size. A larger size puts more space between the nodes. |
beetrees.keybinds |
F, G, J, K, Space, H |
Keys for delete, duplicate, linked duplicate, edit, add node, and help. An empty value turns a key off. |
beetrees.mouseWheel |
pan |
pan: scroll pans, and Ctrl+scroll or a pinch zooms. zoom: scroll zooms, as in the Studio plugin. |
beetrees.taskFileExtension |
.luau |
File extension of new task files. |
beetrees.openTaskBeside |
true |
Open task files next to the tree editor. |
beetrees.openTreesInEditor |
true |
Open behavior tree files in the tree editor. Other default.project.json files still open as text. |
Usage
- Make a tree: right-click a folder in the Explorer and select New Behavior Tree. You can also run BeeTrees: New Behavior Tree from the Command Palette.
- Open a tree: open its
default.project.json. A behavior tree file opens in the tree editor. Other default.project.json files, such as your main Rojo project, open as text. You can also right-click the file and select Open in Behavior Tree Editor, or use the button in the editor title bar.
- Open as text: use the
{} button in the editor title bar. The file then stays text until you close it. To always open trees as text, set beetrees.openTreesInEditor to false.
- Save, undo, and redo: these work as in a text file (
Ctrl+S, Ctrl+Z, Ctrl+Y).
[!IMPORTANT]
Rojo_Id values must be unique in the full Rojo project. Do not copy a tree folder, because the copy has the same IDs. Make a new tree with New Behavior Tree instead.
How a tree is kept on disk
Each tree is a folder that contains a nested Rojo project and one file for each task:
Trees/
Guard/
default.project.json -- the tree; open it with the Behavior Tree Editor
Attack.luau -- task module of the "Attack" node
Wander.luau -- task module of the "Wander" node
Rojo turns a folder that contains default.project.json into the instance that the project describes. For the example above, the result is:
Guard (Folder, tag "_BTree")
Nodes
Root, Node2, Attack, ... (Folder)
Type, Position, Size, Outputs, Parameters, [Weight], [Link], [<task ModuleScript>]
Zoom, WorkspaceX, WorkspaceY
The Outputs and Link ObjectValues point to node folders through the Rojo_Id and Rojo_Target_Value attributes. When a node folder has a different name from its node (for example when two nodes have the same name), the BeeTrees_Name attribute keeps the node name.
The tree name is the name of the folder and the name field in default.project.json. Tree nodes use this name as their TreeID.
Running the trees
Get BehaviorTreeCreator.lua and BehaviorTree3.lua from Defaultio/BehaviorTree3 and put them into your Rojo project. BehaviorTreeCreator requires a child module with the name BehaviorTree5:
"BehaviorTreeCreator": {
"$path": "BehaviorTree3/BehaviorTreeCreator.lua",
"BehaviorTree5": {
"$path": "BehaviorTree3/BehaviorTree3.lua"
}
}
Then run the trees from your game code:
local BehaviorTreeCreator = require(ReplicatedStorage.BehaviorTreeCreator)
local Tree = BehaviorTreeCreator:Create(ServerStorage.Trees.Guard)
Tree:Run(entity)
examples/ contains a full Rojo project with a sample tree. examples/BehaviorTree3/ is a Git submodule of Defaultio/BehaviorTree3. Clone with git clone --recurse-submodules, or run git submodule update --init after you clone. Then run rojo build examples/default.project.json -o Example.rbxlx.
Development
Ensure you have bun installed. This project does not use npm.
Open this folder in VS Code and push F5 to start an Extension Development Host with the example project. A full development environment will be prepared for you.
License and credits
BeeTrees is licensed under the GNU General Public License, version 3. See the LICENSE file.
It is based on the BTrees Studio plugin and the BehaviorTree3 / BehaviorTree5 modules:
- BehaviorTrees2 by oniich_n
- BTrees Visual Editor by tyridge77
- BehaviorTree3 and Behavior Tree Editor V4 by defaultio
- External Task fork by Metaprox