Behavior trees turn character decisions into a hierarchy that designers and programmers can inspect together. They become difficult when a project treats the tree as a dumping ground for every condition, animation request and gameplay side effect. A maintainable tree is less about node count than clear ownership.
Start with observable decisions
Keep durable world knowledge in a blackboard: current target, last known position, alert level and assigned objective. Store temporary execution detail inside tasks. Epic describes the Blackboard as the user-defined key store a Behavior Tree consults when selecting branches. This separation gives debugging tools a stable vocabulary.
Design around intent
Name branches after player-readable intentions—hold cover, investigate sound, revive ally—not implementation mechanics. Put urgent interruptions near the top and define what aborts a running action. A task must report success, failure or cancellation exactly once; hidden retries often create indecisive characters.
Make failure useful
Expose task preconditions and failure reasons. “Move failed” is weak telemetry; “destination outside reachable navmesh” is actionable. Capture selected branch, decisive blackboard values and transition time in a compact trace.
Production checklist
- Keep sensing separate from decision logic.
- Give every long task a cancellation path.
- Rate-limit expensive services.
- Visualise active nodes and relevant key changes.
- Test rapid stimulus changes.
Read the historical Ending the HFSM Tyranny for context.