Optionaloptions: BehaviorTreePluginOptions<G>const ecs = ECSpresso.create()
.withPlugin(createBehaviorTreePlugin())
.build();
const { defineBehaviorTree, action, condition, guard } = ecs.getHelpers(createBehaviorTreeHelpers);
const tree = defineBehaviorTree('villager', {
blackboard: { hunger: 100, targetId: null as number | null },
root: selector([
guard(ctx => ctx.blackboard.hunger < 30, action('eat', ...)),
action('wander', ...),
]),
});
ecs.spawn({
...createBehaviorTree(tree),
...createLocalTransform(100, 200),
});
Create a behavior tree plugin for ECSpresso.
Provides composable, priority-driven AI via behavior trees with:
onAbortcallback when preemptedbehaviorTreeAbortevents on preemption