Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Build NPC AI in Unreal Engine 5 with Behavior Trees and Blackboards: composites (Selector/Sequence), tasks, decorators, services, and running the tree from an AIController. Use when creating enemy/NPC AI, BT_/BB_ assets, custom BTTask or BTService nodes, or when the user mentions Behavior Tree, Blackboard, AIController, BTTask, decorator, or service.
.claude/skills/gamedev-skills-unreal-behavior-trees/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 206% | 0% |
| case-23 | ✓→✓ | = Same ✓ | 43% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 53% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 112% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 72% | 0% |
Author NPC decision-making in UE5 with Behavior Trees driven by a Blackboard: structure the tree with composites, gate branches with decorators, keep state current with services, and run it from an AIController. Targets UE 5.8.
BT_/BB_ asset pair, structuringSelector/Sequence branches, adding decorators (conditions) and services (periodic updates), writing custom BTTask/BTService nodes, or wiring an AIController to run the tree.
BT_) and Blackboard (BB_) assets and anAAIController.
When not to use: the concept of AI (FSM vs BT vs steering, cross-engine) → game-ai. Pure navigation/pathing math is engine navmesh (BT's MoveTo uses it). Simple one-off logic may be cheaper as a small state machine than a full tree.
BB_) holds typed keys (the AI's memory: TargetActor,LastKnownLocation, bIsInvestigating); a Behavior Tree (BT_) references that Blackboard.
AAIController possesses the pawn and calls RunBehaviorTree(BT),which also initializes the referenced Blackboard.
(priority/fallback: "attack, else chase, else patrol"). Sequence runs children until one fails (do-all: "move to cover → reload → peek"). Simple Parallel runs one main task alongside a secondary.
combat branch). Set Observer Aborts so the tree re-evaluates when the key changes.
(e.g. update TargetActor via a sight check) only while that branch is active.
Succeeded, Failed, or InProgress (latent tasks likeMoveTo finish later).
shows live Blackboard values, so you see exactly which branch executes.
cppvoid AEnemyAIController::OnPossess(APawn* InPawn) { Super::OnPossess(InPawn); if (BehaviorTree) // UPROPERTY(EditAnywhere) TObjectPtr<UBehaviorTree> RunBehaviorTree(BehaviorTree); // initializes & uses the Blackboard the BT references }
textROOT └── Selector (try combat, else investigate, else patrol) ├── Sequence [Decorator: Blackboard 'TargetActor' Is Set, Observer Aborts: Both] │ ├── Task: MoveTo (TargetActor) // latent: returns InProgress then Succeeded │ └── Task: Attack ├── Sequence [Decorator: 'LastKnownLocation' Is Set] │ ├── Task: MoveTo (LastKnownLocation) │ └── Task: Wait (3s) + clear key └── Task: Patrol (BTTask_FindPatrolPoint -> MoveTo)
Observer Aborts: Both makes the combat branch interrupt patrol the instant TargetActor is set, and bail out when it's cleared — this is what makes the AI feel reactive.
cppvoid AEnemyAIController::SetTarget(AActor* Target) { if (UBlackboardComponent* BB = GetBlackboardComponent()) BB->SetValueAsObject(TEXT("TargetActor"), Target); // key name must match the BB asset } // Clear with BB->ClearValue(TEXT("TargetActor")); to drop back to a lower-priority branch.
in World or Spawned" and assign the AIController), or RunBehaviorTree was never called.
MoveTo instantly fails — no NavMesh in the level (add a Nav Mesh Bounds Volume), or thetarget is off the navmesh.
None; set it to Self/Lower Priority/Both so the tree re-evaluates when the key changes.
InProgress and never callsFinishLatentTask. Always complete latent tasks.
SetValueAsObject("Taget", ...) silently does nothing; match thekey name and type exactly, or use a cached FBlackboardKeySelector.
(stops on first success). Swapping them inverts the behaviour.
UBTTaskNode (instant and latent ExecuteTask returning EBTNodeResult,with a FBlackboardKeySelector), read references/custom-bttask.md.
(https://dev.epicgames.com/documentation/en-us/unreal-engine/behavior-trees-in-unreal-engine).
game-ai — engine-agnostic AI design (FSM, BT, steering, pathfinding choices).unreal-cpp-gameplay — the AIController and pawn classes in C++.fps-shooter / tower-defense — genres that compose enemy AI.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-16 | fail→fail | 7,718 | 3,748 | -51% | 1 | 1 | 0% | 1,264 | 1,941 | +54% | 0 | 0 | — |
case-23 | pass→pass | 12,438 | 11,224 | -10% | 1 | 1 | 0% | 2,102 | 3,001 | +43% | 0 | 0 | — |
case-01 | pass→pass | 17,683 | 14,488 | -18% | 1 | 1 | 0% | 2,047 | 3,130 | +53% | 0 | 0 | — |
case-02 | pass→pass | 6,206 | 14,500 | +134% | 1 | 1 | 0% | 1,045 | 2,220 | +112% | 0 | 0 | — |
case-03 | pass→pass | 19,419 | 21,044 | +8% | 1 | 1 | 0% | 2,751 | 4,731 | +72% | 0 | 0 | — |
case-04 | pass→pass | 9,102 | 8,145 | -11% | 1 | 1 | 0% | 781 | 1,976 | +153% | 0 | 0 | — |
case-05 | pass→pass | 8,970 | 4,188 | -53% | 1 | 1 | 0% | 583 | 2,027 | +248% | 0 | 0 | — |
case-10 | pass→pass | 4,534 | 9,455 | +109% | 1 | 1 | 0% | 748 | 2,198 | +194% | 0 | 0 | — |
case-06 | pass→pass | 3,346 | 3,262 | -3% | 1 | 1 | 0% | 626 | 1,907 | +205% | 0 | 0 | — |
case-07 | fail→pass | 4,742 | 6,131 | +29% | 1 | 1 | 0% | 778 | 2,378 | +206% | 0 | 0 | — |
case-08 | pass→pass | 4,989 | 9,432 | +89% | 1 | 1 | 0% | 818 | 2,102 | +157% | 0 | 0 | — |
case-09 | pass→pass | 14,254 | 9,724 | -32% | 1 | 1 | 0% | 833 | 2,197 | +164% | 0 | 0 | — |
case-11 | pass→pass | 4,128 | 3,149 | -24% | 1 | 1 | 0% | 734 | 1,915 | +161% | 0 | 0 | — |
case-12 | pass→pass | 17,914 | 14,243 | -20% | 1 | 1 | 0% | 2,188 | 3,026 | +38% | 0 | 0 | — |
case-13 | pass→pass | 9,748 | 4,456 | -54% | 1 | 1 | 0% | 856 | 2,210 | +158% | 0 | 0 | — |
case-14 | pass→pass | 6,170 | 3,847 | -38% | 1 | 1 | 0% | 960 | 1,992 | +108% | 0 | 0 | — |
case-15 | pass→pass | 8,872 | 6,295 | -29% | 1 | 1 | 0% | 1,735 | 2,598 | +50% | 0 | 0 | — |
case-17 | pass→pass | 5,457 | 4,368 | -20% | 1 | 1 | 0% | 898 | 2,067 | +130% | 0 | 0 | — |
case-18 | pass→pass | 4,534 | 4,036 | -11% | 1 | 1 | 0% | 855 | 2,178 | +155% | 0 | 0 | — |
case-19 | pass→pass | 11,520 | 10,235 | -11% | 1 | 1 | 0% | 1,789 | 3,064 | +71% | 0 | 0 | — |
case-20 | pass→pass | 7,618 | 4,797 | -37% | 1 | 1 | 0% | 1,412 | 2,307 | +63% | 0 | 0 | — |
case-21 | pass→pass | 15,736 | 9,776 | -38% | 1 | 1 | 0% | 2,486 | 2,965 | +19% | 0 | 0 | — |
case-22 | pass→pass | 14,014 | 9,886 | -29% | 1 | 1 | 0% | 2,244 | 2,982 | +33% | 0 | 0 | — |
case-24 | pass→pass | 4,859 | 2,939 | -40% | 1 | 1 | 0% | 901 | 1,823 | +102% | 0 | 0 | — |
case-25 | pass→pass | 3,944 | 5,082 | +29% | 1 | 1 | 0% | 689 | 2,188 | +218% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.