ai-behavior-trees-util…
Build a production behavior-tree runtime (Blackboard, action/condition leaves, sequence/selector/parallel composites, decorators) and a Utility AI system…
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
$ npx -y skills add gamedev-skills/awesome-gamedev-agent-skills --skill unreal-behavior-trees --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/unreal-behavior-treesContext preview
The summary Claude sees to decide when to auto-load this skill.
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
name: unreal-behavior-trees description: > 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.
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**.
Selector/Sequence branches, adding decorators (conditions) and services (periodic updates), writing custom `BTTask`/`BTService` nodes, or wiring an AIController to run the tree.
`AAIController`.
**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.
1. **Create the pair:** a Blackboard (`BB_`) holds typed keys (the AI's memory: `TargetActor`, `LastKnownLocation`, `bIsInvestigating`); a Behavior Tree (`BT_`) references that Blackboard. 2. **Possess and run.** An `AAIController` possesses the pawn and calls `RunBehaviorTree(BT)`, which also initializes the referenced Blackboard. 3. **Structure with composites.** **Selector** runs children left→right until one *succeeds* (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. 4. **Gate branches with Decorators** that read Blackboard keys (e.g. "Has Target?" guards the combat branch). Set **Observer Aborts** so the tree re-evaluates when the key changes. 5. **Keep the Blackboard current with Services** attached to a branch — they tick periodically (e.g. update `TargetActor` via a sight check) only while that branch is active. 6. **Do work in Tasks**, which return `Succeeded`, `Failed`, or `InProgress` (latent tasks like `MoveTo` finish later). 7. **Verify** with the Behavior Tree debugger during PIE — it highlights the running node and shows live Blackboard values, so you see exactly which branch executes.
void AEnemyAIController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
if (BehaviorTree) // UPROPERTY(EditAnywhere) TObjectPtr<UBehaviorTree>
RunBehaviorTree(BehaviorTree); // initializes & uses the Blackboard the BT references
}ROOT
└── 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.
void 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.
target is off the navmesh.
None; set it to Self/Lower Priority/Both so the tree re-evaluates when the key changes.
`FinishLatentTask`. Always complete latent tasks.
key name and type exactly, or use a cached `FBlackboardKeySelector`.
(stops on first success). Swapping them inverts the behaviour.
with a `FBlackboardKeySelector`), read `references/custom-bttask.md`.
(`https://dev.epicgames.com/documentation/en-us/unreal-engine/behavior-trees-in-unreal-engine`).
<img src="docs/assets/banner.png" width="820" alt="awesome-gamedev-agent-skills — game-dev skills for AI coding agents.
Repo: gamedev-skills/awesome-gamedev-agent-skills
Build a production behavior-tree runtime (Blackboard, action/condition leaves, sequence/selector/parallel composites, decorators) and a Utility AI system…
Implement game audio practice — bus/mixer architecture and gain in decibels, ducking (sidechain), adaptive/dynamic music via layering and re-sequencing, SFX…
Build game cameras that feel good — 2D follow with a deadzone, look-ahead, smoothing, and level-bounds clamping; 3D third-person orbit with collision and…
Plan, generate, source, normalize, and validate cohesive visual game assets. Use for art direction, style bibles, sprites, tilesets, backgrounds, UI art,…
Build branching dialogue and narrative — a node/choice graph with conditions, variables, and localization hooks — and choose between authoring tools Ink and…
Design NPC and enemy decision-making with finite state machines, behavior trees, steering behaviors, and A* pathfinding — engine-neutral algorithms that pair…