[[ Welcome to ClosureBT ]]

Build Behavior Trees
through composition

ClosureBT is a modern behavior tree framework for Unity that uses C# closures and async patterns to create intuitive, maintainable AI systems.

Quick Start

Create your first behavior tree in just a few lines of code:

AI = Sequence("NPC", () =>
{
    Wait(1);
    Do(() => Debug.Log("Hello"));

    Selector("Make A Choice", () =>
    {
        Sequence(() =>
        {
            Condition("Is Angry", () => IsAngry);
            Pickup("Egg");
            ThrowItemAt(() => Target);
        });

        SomeOtherAction();
    });

    Dance();
    MoveTo("Bed");
});
AI = Sequence("NPC", () =>
{
    Wait(1);
    Do(() => Debug.Log("Hello"));

    Selector("Make A Choice", () =>
    {
        Sequence(() =>
        {
            Condition("Is Angry", () => IsAngry);
            Pickup("Egg");
            ThrowItemAt(() => Target);
        });

        SomeOtherAction();
    });

    Dance();
    MoveTo("Bed");
});
Read the Crash Course →

Key Features

  • Embedded DSL — Clean and simple DSL for declaring nodes
  • Composition based API — Compose behaviors through functions
  • Time Travel Debugging — Visual debugger with the ability to scrub through execution history
  • Async Support — Lifecycle methods with synchronous and asynchronous paths
  • Graceful Interruptions — Handle interruptions predictably and reliably with lifecycle methods
  • Parameterized Nodes — Create nodes that can accept parameters and return values
  • Recursion — Nodes can be recursive, enabling things such as Task Decomposition

Next Steps

Check out our Crash Course to get started quickly with practical examples and step-by-step guidance.

Or dive deeper into the Core Concepts documentation to understand the foundation in detail.