Behavior Designer
Visual behavior tree editors let designers and programmers collaborate on AI by building complex behaviors through drag-and-drop node composition.
Why Visual Behavior Trees?
While you can implement behavior trees purely in code, visual editors provide significant advantages for game development teams:
- Designer-friendly: Game designers can create and tune AI without writing code.
- Visual debugging: See which nodes are active, running, or failed in real-time during play mode.
- Rapid iteration: Drag-and-drop node composition is faster than writing and compiling code.
- Shared vocabulary: The visual tree becomes a communication tool between programmers and designers.
Popular BT Tools for Unity
| Tool | Type | Key Features |
|---|---|---|
| Behavior Designer | Asset Store (paid) | 300+ pre-built tasks, runtime debugging, conditional aborts |
| NodeCanvas | Asset Store (paid) | BT + FSM combo, visual scripting, dialogue trees |
| Fluid Behavior Tree | Open source | Code-first builder pattern, lightweight, no editor dependency |
| Unity Visual Scripting | Built-in | State machines via visual graphs, free with Unity |
Creating Custom Tasks
using UnityEngine; using BehaviorDesigner.Runtime; using BehaviorDesigner.Runtime.Tasks; [TaskCategory("Custom")] [TaskDescription("Check if target is in range")] public class IsTargetInRange : Conditional { public SharedTransform target; public SharedFloat range; public override TaskStatus OnUpdate() { float dist = Vector3.Distance( transform.position, target.Value.position ); return dist <= range.Value ? TaskStatus.Success : TaskStatus.Failure; } } [TaskCategory("Custom")] public class MoveToTarget : Action { public SharedTransform target; public SharedFloat speed; public override TaskStatus OnUpdate() { transform.position = Vector3.MoveTowards( transform.position, target.Value.position, speed.Value * Time.deltaTime ); float dist = Vector3.Distance( transform.position, target.Value.position); return dist < 0.1f ? TaskStatus.Success : TaskStatus.Running; } }
Shared Variables and Blackboard
Behavior Designer uses SharedVariables as its blackboard system. These typed variables (SharedFloat, SharedTransform, SharedBool) can be read and written by any task in the tree, enabling communication between nodes without tight coupling.
Conditional Aborts
Conditional aborts allow a behavior tree to interrupt running tasks when conditions change. For example, if an enemy is running a patrol sequence and suddenly sees the player, a conditional abort on the "Can See Player" check can immediately interrupt patrolling and switch to combat.
- Self: Abort tasks within the same composite node.
- Lower Priority: Abort tasks in lower-priority branches.
- Both: Abort both self and lower priority tasks.
Lilly Tech Systems