Intermediate

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

ToolTypeKey Features
Behavior DesignerAsset Store (paid)300+ pre-built tasks, runtime debugging, conditional aborts
NodeCanvasAsset Store (paid)BT + FSM combo, visual scripting, dialogue trees
Fluid Behavior TreeOpen sourceCode-first builder pattern, lightweight, no editor dependency
Unity Visual ScriptingBuilt-inState machines via visual graphs, free with Unity

Creating Custom Tasks

C# - Custom Behavior Designer Task
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.
Key takeaway: Visual behavior tree tools like Behavior Designer dramatically speed up AI development in Unity. They enable designer-programmer collaboration, provide real-time debugging, and include libraries of pre-built tasks for common game AI patterns.