Learn
What behavior trees are, where they came from, and the handful of building blocks every tree is made of.
New here? Read these in order.
- Behavior trees and their history: what a behavior tree is, why game studios moved to them from state machines, and where they are today.
- Building blocks: the six node types (Action, Condition, Sequence, Fallback, Parallel, Decorator), with pseudocode in Unity C#, Godot GDScript and Unreal C++.
- Decorators as policy: retries, cooldowns, timeouts and guards as small rules you wrap around any action, with a tree to run and code for each engine.
- Recursive composition: write a behavior once as a tree of its own and run it inside other trees as a subtree, with three trees to run and code for each engine.
- Reactive versus memory nodes: whether a sequence starts again from its first child on every tick or resumes the child that was running, and when each is right, with a tree to run and code for each engine.
- Concurrency: doing two things at once with a parallel node, how success and failure policies decide its result, and halting the children still running, with a tree to run and code for each engine.
- Testing and simulation: check that a tree decides what you meant before it reaches a game, by forcing what each leaf returns and comparing runs against a saved golden trace, with a tree to test and test helpers for each engine.
- Debugging and visualization: find out why a tree did what it did by drawing it, reading a trace from the root’s result down to the leaf that decided, and logging the same story from inside a running game, with a tree to debug and a tick log for each engine.
- Data-driven trees: keep a tree in a file the game reads, so designers change its shape and numbers without code, with a node registry, a loader that reloads the tree while the game runs, and how to version and review the file, with a tree to tune and a loader for each engine.
- Event-driven trees: stop ticking the whole tree every frame: tick it only when a blackboard variable it reads changes or an action finishes, and abort the running branch when a higher-priority one applies, with a tree to run and an event-driven runner for each engine.
- Graph structures and blackboards: use one subtree in many places, and see the blackboard as a map of who writes each value and who reads it. Check that each read has a writer first. With a tree to run and a check for each engine.
- Hybrids: utility, state machines and planners: let a behavior tree share decisions with other methods: a utility score that picks the best of several moves, a state machine for modes that last, and a planner that works out the steps to a goal, with a tree to run and code for each engine.
- Scale: many agents on one budget: keep hundreds of agents affordable: share one tree definition, work a costly fact out once for everyone, put cheap checks before costly ones, and tick distant agents less often on a fixed budget, with a tree to run and a tick scheduler for each engine.
- Newer ideas: authoring and repair with a model: let a model draft a tree or fix one. The validator answers its mistakes. Tests you wrote first say if the tree is right. A person reads the change. With a ferryman to run and a playtest log for each engine.
- The tree format: how those blocks are written down in a
.beetree.yamlfile.
When you are ready to try it, open the Build hub.