Try the Visual Editor online!

You can design your Behavior Trees online using the Behavior3JS Visual Editor. It's easy, clean and open source.

Features

  • Based on the work of (Marzinotto et al., 2014), in which they propose a formal, consistent and general definition of Behavior Trees;

  • Optimized to control multiple agents: you can use a single behavior tree instance to handle hundreds of agents;

  • It was designed to load and save trees in a JSON format, in order to use, edit and test it in multiple environments, tools and languages;

  • A cool visual editor which you can access online;

  • Several composite, decorator and action nodes available within the library. You can still define your own nodes, including composites and decorators;

  • Completely free, the core module and the visual editor are all published under the MIT License, which means that you can use them for your open source and commercial projects;

  • Lightweight, only 11.5KB!

// Creating a Behavior Tree
var tree = new b3.BehaviorTree();

tree.root = new b3.Sequence({children: [
    new b3.Priority({children: [
        new MyAction(),
        new Wait(1000)
    ]})
]});

// Creating an Action Node
var MyAction = b3.Class(b3.Action);

MyAction.prototype.name = 'MyAction';

MyAction.prototype.tick = function(tick) {
    // action code here
}

// Using the Behavior Tree
var target = new Image(); // Or any other object
var blackboard = new b3.Blackboard();
tree.tick(target, blackboard);