[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79QHXQE4580VEPNR6RECYJC":3,"skill-same:01M79QHXQE4580VEPNR6RECYJC":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M79QHXQE4580VEPNR6RECYJC","unreal-behavior-trees",null,"Build NPC AI in Unreal Engine 5 with Behavior Trees and Blackboards: composites (Selector\u002FSequence), tasks, decorators, services, and running the tree from an AIController. Use when creating enemy\u002FNPC AI, BT_\u002FBB_ assets, custom BTTask or BTService nodes, or when the user mentions Behavior Tree, Blackboard, AIController, BTTask, decorator, or service.","JunMystery\u002FAgent-Guidance","JunMystery","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161468934?v=4","01M79MTMV8F0BY8NK1A92RA8A0","Jun","01M79MTMWCFBKPHN5B25E6V20B",0,"MIT","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Funreal-behavior-trees\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: unreal-behavior-trees\ndescription: >\n  Build NPC AI in Unreal Engine 5 with Behavior Trees and Blackboards: composites\n  (Selector\u002FSequence), tasks, decorators, services, and running the tree from an AIController.\n  Use when creating enemy\u002FNPC AI, BT_\u002FBB_ assets, custom BTTask or BTService nodes, or when\n  the user mentions Behavior Tree, Blackboard, AIController, BTTask, decorator, or service.\n---\n\n# Unreal Behavior Trees\n\nAuthor NPC decision-making in UE5 with Behavior Trees driven by a Blackboard: structure the\ntree with composites, gate branches with decorators, keep state current with services, and run\nit from an AIController. Targets **UE 5.8**.\n\n## When to use\n\n- Use when building enemy\u002FNPC AI: creating a `BT_`\u002F`BB_` asset pair, structuring\n  Selector\u002FSequence branches, adding decorators (conditions) and services (periodic updates),\n  writing custom `BTTask`\u002F`BTService` nodes, or wiring an AIController to run the tree.\n- Use when the project has Behavior Tree (`BT_`) and Blackboard (`BB_`) assets and an\n  `AAIController`.\n\n**When *not* to use:** the *concept* of AI (FSM vs BT vs steering, cross-engine) →\n`game-ai`. Pure navigation\u002Fpathing math is engine navmesh (BT's `MoveTo` uses it). Simple\none-off logic may be cheaper as a small state machine than a full tree.\n\n**Behavior Tree or StateTree?** UE 5.8 ships both, and Behavior Trees are not deprecated.\nStateTree is Epic's general-purpose hierarchical state machine: it combines BT-style\nselection with explicit States and Transitions. If the project already uses StateTree\nassets, or the AI is naturally a set of modes with clear transitions (patrol → alert →\ncombat), check with the user before adding a Behavior Tree next to it. Keep using Behavior\nTrees where the project already has `BT_`\u002F`BB_` assets.\n\n## Core workflow\n\n1. **Create the pair:** a Blackboard (`BB_`) holds typed keys (the AI's memory: `TargetActor`,\n   `LastKnownLocation`, `bIsInvestigating`); a Behavior Tree (`BT_`) references that Blackboard.\n2. **Possess and run.** An `AAIController` possesses the pawn and calls `RunBehaviorTree(BT)`,\n   which also initializes the referenced Blackboard.\n3. **Structure with composites.** **Selector** runs children left→right until one *succeeds*\n   (priority\u002Ffallback: \"attack, else chase, else patrol\"). **Sequence** runs children until one\n   *fails* (do-all: \"move to cover → reload → peek\"). **Simple Parallel** runs one main task\n   alongside a secondary.\n4. **Gate branches with Decorators** that read Blackboard keys (e.g. \"Has Target?\" guards the\n   combat branch). Set **Observer Aborts** so the tree re-evaluates when the key changes.\n5. **Keep the Blackboard current with Services** attached to a branch — they tick periodically\n   (e.g. update `TargetActor` via a sight check) only while that branch is active.\n6. **Do work in Tasks**, which return `Succeeded`, `Failed`, or `InProgress` (latent tasks like\n   `MoveTo` finish later).\n7. **Verify** with the Behavior Tree debugger during PIE — it highlights the running node and\n   shows live Blackboard values, so you see exactly which branch executes.\n\n## Patterns\n\n### 1. AIController that runs the tree (C++)\n\n```cpp\nvoid AEnemyAIController::OnPossess(APawn* InPawn)\n{\n    Super::OnPossess(InPawn);\n    if (BehaviorTree)                 \u002F\u002F UPROPERTY(EditAnywhere) TObjectPtr\u003CUBehaviorTree>\n        RunBehaviorTree(BehaviorTree); \u002F\u002F initializes & uses the Blackboard the BT references\n}\n```\n\n### 2. A priority tree (node structure)\n\n```text\nROOT\n└── Selector (try combat, else investigate, else patrol)\n    ├── Sequence            [Decorator: Blackboard 'TargetActor' Is Set, Observer Aborts: Both]\n    │     ├── Task: MoveTo (TargetActor)          \u002F\u002F latent: returns InProgress then Succeeded\n    │     └── Task: Attack\n    ├── Sequence            [Decorator: 'LastKnownLocation' Is Set]\n    │     ├── Task: MoveTo (LastKnownLocation)\n    │     └── Task: Wait (3s) + clear key\n    └── Task: Patrol (BTTask_FindPatrolPoint -> MoveTo)\n```\n\n`Observer Aborts: Both` makes the combat branch interrupt patrol the instant `TargetActor` is\nset, and bail out when it's cleared — this is what makes the AI feel reactive.\n\n### 3. Updating the Blackboard from code (e.g. on seeing the player)\n\n```cpp\nvoid AEnemyAIController::SetTarget(AActor* Target)\n{\n    if (UBlackboardComponent* BB = GetBlackboardComponent())\n        BB->SetValueAsObject(TEXT(\"TargetActor\"), Target);   \u002F\u002F key name must match the BB asset\n}\n\u002F\u002F Clear with BB->ClearValue(TEXT(\"TargetActor\")); to drop back to a lower-priority branch.\n```\n\n## Pitfalls\n\n- **AI never starts** — the pawn isn't possessed (set the Pawn's *Auto Possess AI* to \"Placed\n  in World or Spawned\" and assign the AIController), or `RunBehaviorTree` was never called.\n- **`MoveTo` instantly fails** — no NavMesh in the level (add a Nav Mesh Bounds Volume), or the\n  target is off the navmesh.\n- **Branch doesn't react to changes** — the gating Decorator's **Observer Aborts** is set to\n  None; set it to Self\u002FLower Priority\u002FBoth so the tree re-evaluates when the key changes.\n- **A task hangs the tree** — a custom task returned `InProgress` and never calls\n  `FinishLatentTask`. Always complete latent tasks.\n- **AI behaves strangely only when several NPCs share a tree** — a custom task stores run state\n  in member variables. Task nodes are shared by every AI using the asset unless instanced; keep\n  per-AI state in node memory (see the reference).\n- **Blackboard key typos** — `SetValueAsObject(\"Taget\", ...)` silently does nothing; match the\n  key name and type exactly, or use a cached `FBlackboardKeySelector`.\n- **Sequence vs Selector confusion** — Sequence = AND (stops on first failure); Selector = OR\n  (stops on first success). Swapping them inverts the behaviour.\n\n## References\n\n- For a **custom C++ `UBTTaskNode`** (instant and latent `ExecuteTask` returning `EBTNodeResult`,\n  per-AI node memory, `AbortTask`, and a `FBlackboardKeySelector`), read\n  `references\u002Fcustom-bttask.md`.\n- Primary docs: \"Behavior Trees in Unreal Engine\"\n  (`https:\u002F\u002Fdev.epicgames.com\u002Fdocumentation\u002Fen-us\u002Funreal-engine\u002Fbehavior-trees-in-unreal-engine`).\n\n## Related skills\n\n- `game-ai` — engine-agnostic AI design (FSM, BT, steering, pathfinding choices).\n- `unreal-cpp-gameplay` — the AIController and pawn classes in C++.\n- `fps-shooter` \u002F `tower-defense` — genres that compose enemy AI.\n","# Unreal Behavior Trees\n\nAuthor NPC decision-making in UE5 with Behavior Trees driven by a Blackboard: structure the\ntree with composites, gate branches with decorators, keep state current with services, and run\nit from an AIController. Targets **UE 5.8**.\n\n## When to use\n\n- Use when building enemy\u002FNPC AI: creating a `BT_`\u002F`BB_` asset pair, structuring\n  Selector\u002FSequence branches, adding decorators (conditions) and services (periodic updates),\n  writing custom `BTTask`\u002F`BTService` nodes, or wiring an AIController to run the tree.\n- Use when the project has Behavior Tree (`BT_`) and Blackboard (`BB_`) assets and an\n  `AAIController`.\n\n**When *not* to use:** the *concept* of AI (FSM vs BT vs steering, cross-engine) →\n`game-ai`. Pure navigation\u002Fpathing math is engine navmesh (BT's `MoveTo` uses it). Simple\none-off logic may be cheaper as a small state machine than a full tree.\n\n**Behavior Tree or StateTree?** UE 5.8 ships both, and Behavior Trees are not deprecated.\nStateTree is Epic's general-purpose hierarchical state machine: it combines BT-style\nselection with explicit States and Transitions. If the project already uses StateTree\nassets, or the AI is naturally a set of modes with clear transitions (patrol → alert →\ncombat), check with the user before adding a Behavior Tree next to it. Keep using Behavior\nTrees where the project already has `BT_`\u002F`BB_` assets.\n\n## Core workflow\n\n1. **Create the pair:** a Blackboard (`BB_`) holds typed keys (the AI's memory: `TargetActor`,\n   `LastKnownLocation`, `bIsInvestigating`); a Behavior Tree (`BT_`) references that Blackboard.\n2. **Possess and run.** An `AAIController` possesses the pawn and calls `RunBehaviorTree(BT)`,\n   which also initializes the referenced Blackboard.\n3. **Structure with composites.** **Selector** runs children left→right until one *succeeds*\n   (priority\u002Ffallback: \"attack, else chase, else patrol\"). **Sequence** runs children until one\n   *fails* (do-all: \"move to cover → reload → peek\"). **Simple Parallel** runs one main task\n   alongside a secondary.\n4. **Gate branches with Decorators** that read Blackboard keys (e.g. \"Has Target?\" guards the\n   combat branch). Set **Observer Aborts** so the tree re-evaluates when the key changes.\n5. **Keep the Blackboard current with Services** attached to a branch — they tick periodically\n   (e.g. update `TargetActor` via a sight check) only while that branch is active.\n6. **Do work in Tasks**, which return `Succeeded`, `Failed`, or `InProgress` (latent tasks like\n   `MoveTo` finish later).\n7. **Verify** with the Behavior Tree debugger during PIE — it highlights the running node and\n   shows live Blackboard values, so you see exactly which branch executes.\n\n## Patterns\n\n### 1. AIController that runs the tree (C++)\n\n```cpp\nvoid AEnemyAIController::OnPossess(APawn* InPawn)\n{\n    Super::OnPossess(InPawn);\n    if (BehaviorTree)                 \u002F\u002F UPROPERTY(EditAnywhere) TObjectPtr\u003CUBehaviorTree>\n        RunBehaviorTree(BehaviorTree); \u002F\u002F initializes & uses the Blackboard the BT references\n}\n```\n\n### 2. A priority tree (node structure)\n\n```text\nROOT\n└── Selector (try combat, else investigate, else patrol)\n    ├── Sequence            [Decorator: Blackboard 'TargetActor' Is Set, Observer Aborts: Both]\n    │     ├── Task: MoveTo (TargetActor)          \u002F\u002F latent: returns InProgress then Succeeded\n    │     └── Task: Attack\n    ├── Sequence            [Decorator: 'LastKnownLocation' Is Set]\n    │     ├── Task: MoveTo (LastKnownLocation)\n    │     └── Task: Wait (3s) + clear key\n    └── Task: Patrol (BTTask_FindPatrolPoint -> MoveTo)\n```\n\n`Observer Aborts: Both` makes the combat branch interrupt patrol the instant `TargetActor` is\nset, and bail out when it's cleared — this is what makes the AI feel reactive.\n\n### 3. Updating the Blackboard from code (e.g. on seeing the player)\n\n```cpp\nvoid AEnemyAIController::SetTarget(AActor* Target)\n{\n    if (UBlackboardComponent* BB = GetBlackboardComponent())\n        BB->SetValueAsObject(TEXT(\"TargetActor\"), Target);   \u002F\u002F key name must match the BB asset\n}\n\u002F\u002F Clear with BB->ClearValue(TEXT(\"TargetActor\")); to drop back to a lower-priority branch.\n```\n\n## Pitfalls\n\n- **AI never starts** — the pawn isn't possessed (set the Pawn's *Auto Possess AI* to \"Placed\n  in World or Spawned\" and assign the AIController), or `RunBehaviorTree` was never called.\n- **`MoveTo` instantly fails** — no NavMesh in the level (add a Nav Mesh Bounds Volume), or the\n  target is off the navmesh.\n- **Branch doesn't react to changes** — the gating Decorator's **Observer Aborts** is set to\n  None; set it to Self\u002FLower Priority\u002FBoth so the tree re-evaluates when the key changes.\n- **A task hangs the tree** — a custom task returned `InProgress` and never calls\n  `FinishLatentTask`. Always complete latent tasks.\n- **AI behaves strangely only when several NPCs share a tree** — a custom task stores run state\n  in member variables. Task nodes are shared by every AI using the asset unless instanced; keep\n  per-AI state in node memory (see the reference).\n- **Blackboard key typos** — `SetValueAsObject(\"Taget\", ...)` silently does nothing; match the\n  key name and type exactly, or use a cached `FBlackboardKeySelector`.\n- **Sequence vs Selector confusion** — Sequence = AND (stops on first failure); Selector = OR\n  (stops on first success). Swapping them inverts the behaviour.\n\n## References\n\n- For a **custom C++ `UBTTaskNode`** (instant and latent `ExecuteTask` returning `EBTNodeResult`,\n  per-AI node memory, `AbortTask`, and a `FBlackboardKeySelector`), read\n  `references\u002Fcustom-bttask.md`.\n- Primary docs: \"Behavior Trees in Unreal Engine\"\n  (`https:\u002F\u002Fdev.epicgames.com\u002Fdocumentation\u002Fen-us\u002Funreal-engine\u002Fbehavior-trees-in-unreal-engine`).\n\n## Related skills\n\n- `game-ai` — engine-agnostic AI design (FSM, BT, steering, pathfinding choices).\n- `unreal-cpp-gameplay` — the AIController and pawn classes in C++.\n- `fps-shooter` \u002F `tower-defense` — genres that compose enemy AI.\n",{"name":5,"description":7},"main","5d0a87185c0e172c3901e2a6e5916b6d544b8b94","skills\u002Funreal-behavior-trees","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance","https:\u002F\u002Fgithub.com\u002FJunMystery","AI is the typist, I am the architect. Building efficient, secure, and user-centric products through disciplined AI prompt engineering.","2026-11-13 17:41:25",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add JunMystery\u002FAgent-Guidance --skill unreal-behavior-trees",{"tool":37,"command":38},"bunx","bunx skills add JunMystery\u002FAgent-Guidance --skill unreal-behavior-trees",{"tool":40,"command":41},"pnpm","pnpm dlx skills add JunMystery\u002FAgent-Guidance --skill unreal-behavior-trees","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Funreal-behavior-trees\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fcustom-bttask.md","REFERENCE","参考文档",6518,"https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Funreal-behavior-trees\u002Freferences\u002Fcustom-bttask.md",[52,58,64,70,76,82],{"skillNo":53,"name":54,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M79QR1E309VJ6CTQKB32AWWA","zero-trust-architecture-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-architecture-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M79QQV7GHYR02DYGN41S23WN","xss-filter-evasion-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxss-filter-evasion-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M79QQNSN7YB8XB61FFSCS3WH","xs-leaks-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxs-leaks-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M79QQHZZJKFDY9132G5A65C2","xpath-injection-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxpath-injection-prevention-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M79QQB9ZSD3DJG8658EHQXR1","xml-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-security-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M79QQ60WKV7PFMXWT9CW8PM6","xml-external-entity-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-external-entity-prevention-cheat-sheet\u002FSKILL.md",[],[]]