Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

unreal-behavior-trees

БесплатноБез исполняемых скриптовНе проверен

Unreal Engine 5 (UE 5.8) NPC AI with Behavior Trees, Blackboards, EQS and StateTree: decorators with Observer Aborts, C++ BTTask nodes and running trees from…

gamedev-skillsот gamedev-skills★ 12 656 звёзд на GitHub

Об этом скилле

Unreal Behavior Trees, EQS and StateTree

Author NPC decision-making in UE5: a Behavior Tree reads a Blackboard, decorators gate branches, services keep keys fresh, EQS picks locations or targets, and an AIController runs it all. StateTree is the alternative for mode-based AI. Targets UE 5.8.

When to use

  • Creating or fixing BT_/BB_ assets, decorators, services, custom BTTask/BTService/ BTDecorator C++ nodes, or the AIController that runs the tree.
  • Writing or debugging EQS queries (EQS_ assets, Run EQS Query, the EQS Testing Pawn).
  • Building AI with StateTree (ST_ assets, UStateTreeAIComponent) or mixing it with a BT.

When not to use: writing your own behavior-tree or utility-AI runtime, outside Unreal's assets → ai-behavior-trees-utility-ai. Choosing an AI architecture or engine-neutral steering and pathfinding → game-ai. The pawn and controller classes themselves → unreal-cpp-gameplay.

Behavior Tree or StateTree?

Both ship in UE 5.8 and Behavior Trees are not deprecated. Default: keep whatever the project already uses. For a new AI, pick StateTree when the behavior is a set of modes with explicit transitions (patrol, alert, combat), and a Behavior Tree when it is a priority list that must re-evaluate when Blackboard values change. They also combine: the BT task Run State Tree (UBTTask_RunStateTree) runs a StateTree inside a branch, and StateTree has its own Run Env Query task for EQS. StateTree on an AI needs the StateTree and GameplayStateTree plugins and a UStateTreeAIComponent on the AIController, with an asset that uses the StateTree AI Component schema. Ask before adding a second system beside the first.

Workflow

  1. Read the project first. Check EngineAssociation in the .uproject (this skill targets 5.8). List existing AI assets and classes so you extend them instead of duplicating: find Content -name "BT_*" -o -name "BB_*" -o -name "EQS_*" -o -name "ST_*" and grep -rn "AAIController\|RunBehaviorTree\|UStateTreeAIComponent" Source. C++ AI code needs "AIModule" in the module's *.Build.cs.
  2. Blackboard (BB_) first. One typed key per fact the AI remembers (TargetActor, LastKnownLocation, bIsInvestigating). The tree references this asset.
  3. Run it from the controller. The pawn's AIController calls RunBehaviorTree(BT) in OnPossess; that also initializes the Blackboard. Set the pawn's Auto Possess AI to "Placed in World or Spawned" and its AI Controller Class.
  4. Shape the tree. Root Selector for priorities (combat, else investigate, else patrol); Sequences for steps that must all succeed. Put a Blackboard decorator on each priority branch and set Observer Aborts so a key change interrupts the running branch.
  5. Keep keys fresh with services on the branch that needs them (perception, distance checks). A service ticks only while its branch is active.
  6. Use EQS for "where" and "which" questions (cover point, nearest pickup): add a Run EQS Query task, set its Query Template and the Blackboard key that receives the best item, and pass parameters through Query Config.
  7. Write custom nodes in C++ only when the built-ins can't do it; read the reference below.
  8. Check it (see Verify).

Patterns

AIController that runs the tree (C++)

void AEnemyAIController::OnPossess(APawn* InPawn)
{
    Super::OnPossess(InPawn);
    if (BehaviorTree)                  // UPROPERTY(EditAnywhere) TObjectPtr<UBehaviorTree>
    {
        RunBehaviorTree(BehaviorTree); // also initializes the Blackboard the BT references
    }
}

void AEnemyAIController::SetTarget(AActor* Target)
{
    if (UBlackboardComponent* BB = GetBlackboardComponent())
    {
        BB->SetValueAsObject(TEXT("TargetActor"), Target); // must match the BB key name
    }
}
// BB->ClearValue(TEXT("TargetActor")) drops the tree back to a lower-priority branch.

A reactive priority tree

ROOT
└── Selector
    ├── Sequence   [Blackboard: TargetActor Is Set, Observer Aborts: Both]
    │     ├── MoveTo (TargetActor)
    │     └── Attack
    ├── Sequence   [Blackboard: LastKnownLocation Is Set, Observer Aborts: Lower Priority]
    │     ├── MoveTo (LastKnownLocation)
    │     └── Wait 3s, then clear the key
    └── Sequence   (patrol)
          ├── Run EQS Query (EQS_NextPatrolPoint -> PatrolLocation)
          └── MoveTo (PatrolLocation)

Both on the combat branch means: start combat the moment TargetActor is set, and leave it the moment it is cleared.

Verify

Say which of these you actually ran; reading the assets is not a test.

  1. Compile the module (Windows: Engine/Build/BatchFiles/Build.bat <Project>Editor Win64 Development -Project="<path>.uproject" -WaitMutex; Linux and macOS use Engine/Build/BatchFiles/Linux/Build.sh or Mac/Build.sh with the matching platform) and fix every error and warning in your files.
  2. **Validate ass
Полный SKILL.md на GitHub

Установить unreal-behavior-trees в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/custom-bttask.md

FAQ

Что делает скилл unreal-behavior-trees?

Unreal Engine 5 (UE 5.8) NPC AI with Behavior Trees, Blackboards, EQS and StateTree: decorators with Observer Aborts, C++ BTTask nodes and running trees from an AIController. Use for UE enemy AI, BT_, BB_ or EQS_ assets, "my AI just stands there" or "MoveTo fails". Not for engine-neutral BT or utility code (`ai-behavior-trees-utility-ai`) or choosing FSM vs BT (`game-ai`).

Как установить скилл unreal-behavior-trees?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл unreal-behavior-trees запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить unreal-behavior-trees с