unreal-behavior-trees
Fungsinya
Skill ini menjelaskan cara mengatur AI karakter non-pemain di Unreal Engine 5 memakai behavior tree. Skill ini untuk pengembang yang membuat musuh atau karakter game yang mengambil keputusan.
Kapan dipakai
- βSaat Anda membuat musuh atau NPC yang harus memilih tindakannya sendiri di Unreal Engine 5.
- βKetika Anda perlu menambahkan kondisi atau pengecekan berkala pada struktur keputusan AI.
- βKetika Anda ingin membuat node perilaku sendiri atau menghubungkan AI controller ke behavior tree.
Link skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unreal/unreal-behavior-trees/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBuat musuh Unreal saya berpatroli sampai melihat pemain, lalu mengejarnya.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill ini menjelaskan cara menyusun pohon dengan selector dan sequence, menambahkan kondisi dan pembaruan latar belakang, serta menjalankan pohon dari AI controller yang memakai Blackboard untuk informasi bersama.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Unreal Behavior Trees
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.
When to use
- Use when building enemy/NPC AI: creating a
BT_/BB_asset pair, structuring Selector/Sequence branches, adding decorators (conditions) and services (periodic updates), writing customBTTask/BTServicenodes, or wiring an AIController to run the tree. - Use when the project has Behavior 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.
Behavior Tree or StateTree? UE 5.8 ships both, and Behavior Trees are not deprecated.
StateTree is Epic's general-purpose hierarchical state machine: it combines BT-style
selection with explicit States and Transitions. If the project already uses StateTree
assets, or the AI is naturally a set of modes with clear transitions (patrol β alert β
combat), check with the user before adding a Behavior Tree next to it. Keep using Behavior
Trees where the project already has BT_/BB_ assets.
Core workflow
- Create the pair: a Blackboard (
BB_) holds typed keys (the AI's memory:TargetActor,LastKnownLocation,bIsInvestigating); a Behavior Tree (BT_) references that Blackboard. - Possess and run. An
AAIControllerpossesses the pawn and callsRunBehaviorTree(BT), which also initializes the referenced Blackboard. - 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.
- 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.
- Keep the Blackboard current with Services attached to a branch β they tick periodically
(e.g. update
TargetActorvia a sight check) only while that branch is active. - Do work in Tasks, which return
Succeeded,Failed, orInProgress(latent tasks likeMoveTofinish later). - 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.
Patterns
1. AIController that runs the tree (C++)
void AEnemyAIController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
if (BehaviorTree) // UPROPERTY(EditAnywhere) TObjectPtr<UBehaviorTree>
RunBehaviorTree(BehaviorTree); // initializes & uses the Blackboard the BT references
}
2. A priority tree (node structure)
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.
3. Updating the Blackboard from code (e.g. on seeing the player)
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.
Pitfalls
- AI never starts β the pawn isn't possessed (set the Pawn's Auto Possess AI to "Placed
in World or Spawned" and assign the AIController), or
RunBehaviorTreewas never called. MoveToinstantly fails β no NavMesh in the level (add a Nav Mesh Bounds Volume), or the target is off the navmesh.- **Branch doesn't rea
Pertanyaan umum
Apa itu Blackboard?
Blackboard adalah penyimpan informasi bersama, misalnya posisi pemain, yang dibaca oleh behavior tree.
Haruskah saya memakai StateTree sebagai gantinya?
Skill ini menyarankan untuk bertanya dulu kepada pengguna, karena keduanya ada di Unreal Engine 5.8 dan proyek mungkin sudah memakai salah satunya.
Apakah ini membahas matematika pathfinding?
Tidak mendalam. Pergerakan memakai sistem navigasi engine, yang merupakan topik terpisah.
Detail
Deskripsi asli dari pembuat
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.
Popularitas
- Bintang GitHub
- 6.6k
- Peringkat
- #13852
- Lisensi
- Apache-2.0
- Diperbarui
- 28/10/2026
Komentar
- β¦
Skill lain dari repositori ini
router
6.6kMembantu agent Anda memilih skill pengembangan game yang tepat untuk setiap permintaan dengan mendeteksi engine Anda dan jenis tugas yang Anda perlukan.
ai-behavior-trees-utility-ai
6.6kMembantu agent Anda membangun behavior tree dan sistem utility AI untuk musuh dan karakter game yang memilih aksi berdasarkan prioritas dan skor.
audio-design
6.6kMengajari agent Anda cara mixing audio game: bus, volume dalam desibel, ducking di bawah dialog, musik adaptif, dan variasi efek suara.
camera-systems
6.6kMembantu agent Anda membangun kamera game yang mengikuti dengan halus, tetap berada di dalam level, dan dapat mengorbit atau melihat sekeliling dalam 3D.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.