# Behavior Trees in Unreal Engine

> How Unreal's behavior trees, blackboards, tasks, decorators and services fit together, how UE differs from classic BTs, and a working patrol/chase tree.
>
> Source: https://www.behaviortrees.com/learn/behavior-trees-in-unreal-engine/
> Updated: 2026-07-20

<div class="disclosure">Disclosure: some links on this page are affiliate links. If you buy
through them we may earn a commission at no extra cost to you.</div>

Unlike Unity, **Unreal Engine ships behavior trees as a first-class engine feature** — the
same system Epic uses internally, wired into the AI Controller, Blackboard, and Environment
Query System (EQS). If you're building AI in UE, behavior trees aren't one option among
many; they're the paved road.

Everything here applies to both UE4 and UE5: the behavior tree system hasn't changed between
them. UE5 also ships StateTree, a hierarchical state machine used with Mass AI and some
gameplay logic, but behavior trees are still the usual choice for character AI.

This guide explains the moving parts and — importantly — where Unreal's implementation
*differs* from the textbook behavior tree model taught in
[our introduction](https://www.behaviortrees.com/learn/what-is-a-behavior-tree/).

## The cast of characters

Building UE AI involves four assets/classes working together:

- **AIController** — possesses the Pawn and runs the behavior tree (`RunBehaviorTree`).
- **[Blackboard](https://www.behaviortrees.com/learn/behavior-tree-blackboard/)** — a key/value store (target actor,
  last known location, flee flag) that is the tree's working memory. Tasks read and write
  it; decorators observe it.
- **Behavior Tree asset** — the tree itself, edited in UE's node graph editor.
- **Tasks, Decorators, Services** — the node types you implement in Blueprint or C++.

## UE's node types, translated

If you know classic BT vocabulary, UE maps almost one-to-one:

| Classic concept | Unreal equivalent |
|-----------------|-------------------|
| Selector / Priority | **Selector** composite |
| Sequence | **Sequence** composite |
| Parallel | **Simple Parallel** composite |
| Action leaf | **Task** (e.g. `MoveTo`, `Wait`, custom `BTTask_`) |
| Condition | **Decorator** (attached to a node, gates execution) |
| — no classic equivalent — | **Service** (runs periodically while a branch is active) |

Two things trip up people coming from textbook BTs:

1. **Conditions aren't leaves.** In UE, a condition is a *decorator attached to* a
   composite or task, not a child node. "Is player visible?" becomes a Blackboard decorator
   on the Chase branch, gating it.
2. **UE trees are event-driven, not naively ticked.** Instead of re-evaluating the whole
   tree from the root every frame, UE's decorators *observe* blackboard keys and abort
   running branches when values change (the "Observer Aborts" setting: None / Self / Lower
   Priority / Both). Same reactive semantics, much cheaper — but it means priority
   preemption only happens where you've configured aborts, which is the #1 source of
   ["why won't my tree switch branches?"](https://www.behaviortrees.com/learn/debugging-behavior-trees/) confusion.

## A minimal working setup

The standard patrol/chase enemy in UE terms:

```text
Root
└── Selector
    ├── [Decorator: Blackboard "TargetActor" is set, Observer Aborts: Lower Priority]
    │   Sequence "Combat"
    │   ├── Task: Move To (TargetActor)
    │   └── Task: Attack
    └── Sequence "Patrol"
        ├── Task: Move To (NextWaypoint)
        ├── Task: Wait 2.0s (±deviation)
        └── Task: Advance waypoint index
```

A **Service** on the Selector runs every ~0.5s doing the perception check and writing
`TargetActor` to the blackboard; the observer-abort decorator then yanks execution out of
Patrol the moment a target appears. That service+observer pattern *is* idiomatic UE AI.

(UE's AI Perception component can update the blackboard for you; EQS answers spatial
queries like "find a flanking position." Layer them in after the basic loop works.)

## Design before you build

UE's graph editor is where trees get *implemented*, but it's a heavyweight place to
*think* — every experiment means creating task assets and blackboard keys. It's faster to
sketch the design first: rough out branches, priorities, and required conditions in the
free [online behavior tree editor](https://www.behaviortrees.com/), iterate until the logic reads right, then translate
into UE assets (conditions become decorators, remember).

<a class="try-editor" href="/?example=enemy-patrol">▶ Sketch a patrol/chase/attack tree first</a>

## Going deeper

- Epic's official [Behavior Tree documentation and quick-start](https://dev.epicgames.com/documentation/en-us/unreal-engine/behavior-trees-in-unreal-engine)
  are genuinely good — do the quick-start once before building your own.
- For a book-length UE5 walkthrough, Marco Secchi's *Artificial Intelligence in Unreal
  Engine 5* (2024) spends three chapters on behavior trees, blackboards, custom tasks,
  services, decorators, and runtime debugging, in both Blueprints and C++
  ([Amazon](https://www.amazon.com/dp/1836205856?tag=behaviortrees-20)).
- For the theory underneath (why trees, utility hybrids, formal semantics), **Ian
  Millington's *AI for Games***
  ([Amazon](https://www.amazon.com/dp/1138483974?tag=behaviortrees-20))
  and the free [Game AI Pro chapters](https://www.gameaipro.com/) are the standard references.

## Related guides

- [Sequence, Selector, and Decorator Nodes Explained](https://www.behaviortrees.com/learn/behavior-tree-nodes-explained/)
- [Behavior Trees vs Finite State Machines](https://www.behaviortrees.com/learn/behavior-trees-vs-state-machines/)
- [Behavior Tree Examples: Common Game AI Patterns](https://www.behaviortrees.com/learn/behavior-tree-examples/)
- Comparing engines? [Best Behavior Tree Tools by Engine](https://www.behaviortrees.com/learn/best-behavior-tree-tools/)
