Editor Workflow
Workflow Overview
Section titled “Workflow Overview”- Design - Plan your AI behavior
- Create - Build the tree in the editor
- Configure - Set up blackboard and properties
- Test - Debug in the editor
- Export - Generate runtime assets
- Integrate - Use in your game
Design Phase
Section titled “Design Phase”Before opening the editor, plan your AI:
Enemy AI Design:├── If health > 50%│ ├── Find target│ ├── Move to target│ └── Attack└── Else └── Flee to safetyCreate Phase
Section titled “Create Phase”Translate your design to nodes:
- Start with a Selector (main decision)
- Add Sequences for each branch
- Add Conditions and Actions
- Configure node properties
Configure Phase
Section titled “Configure Phase”Blackboard Setup
Section titled “Blackboard Setup”Define variables your tree needs:
| Variable | Type | Default | Description |
|---|---|---|---|
| health | number | 100 | Current health |
| target | Entity | null | Attack target |
| homePosition | Vector2 | (0,0) | Safe position |
Property Bindings
Section titled “Property Bindings”Connect node properties to blackboard:
Attack Node: damage: @blackboard.attackPower target: @blackboard.targetTest Phase
Section titled “Test Phase”- Click Play in the editor
- Watch node execution
- Monitor blackboard values
- Step through execution
- Fix issues and repeat
Export Phase
Section titled “Export Phase”Export your tree for runtime use:
// The exported JSON can be loaded at runtimeconst treeData = await loadBehaviorTree('assets/enemy-ai.json');Integration Phase
Section titled “Integration Phase”import { BehaviorTreeLoader, BehaviorTreeStarter } from '@esengine/behavior-tree';
// Load exported treeconst treeData = await BehaviorTreeLoader.load('enemy-ai.json');
// Attach to entityconst enemy = scene.createEntity('Enemy');BehaviorTreeStarter.start(enemy, treeData);