unreal-behavior-trees
Qué hace
Explica cómo configurar la IA de personajes no jugadores en Unreal Engine 5 usando árboles de comportamiento. Es para desarrolladores que crean enemigos u otros personajes que toman decisiones.
Cuándo usarla
- ✓Cuando construyes un enemigo o un PNJ que debe elegir sus acciones en Unreal Engine 5.
- ✓Cuando necesitas añadir condiciones o comprobaciones periódicas a una estructura de decisiones de IA.
- ✓Cuando quieres escribir nodos de comportamiento personalizados o conectar un controlador de IA a un árbol de comportamiento.
Link de la skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unreal/unreal-behavior-trees/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Haz que mi enemigo de Unreal patrulle hasta que vea al jugador y después lo persiga.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
Explica cómo organizar el árbol con selectores y secuencias, añadir condiciones y actualizaciones en segundo plano, y ejecutar el árbol desde un controlador de IA que usa una Blackboard para la información compartida.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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
Preguntas frecuentes
¿Qué es una Blackboard?
Una Blackboard es un almacén compartido de información, como la posición del jugador, que el árbol de comportamiento lee.
¿Debo usar StateTree en su lugar?
La skill indica consultar primero con el usuario, porque ambos sistemas existen en Unreal Engine 5.8 y un proyecto puede usar ya uno de ellos.
¿Cubre las matemáticas de búsqueda de caminos?
No en profundidad. El movimiento usa el sistema de navegación del motor, que es un tema aparte.
Detalles
Descripción original del autor
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.
Popularidad
- Estrellas en GitHub
- 6,6 mil
- Posición en el ranking
- #13852
- Licencia
- Apache-2.0
- Actualizada
- 28/10/2026
Comentarios
- …
Más skills de este repositorio
router
6,6 milAyuda a tu agente a elegir la skill de desarrollo de juegos adecuada para cada petición, detectando tu motor y el tipo de tarea que necesitas.
ai-behavior-trees-utility-ai
6,6 milAyuda a tu agente a construir un árbol de comportamiento y un sistema de IA por utilidad para enemigos y personajes que eligen acciones según prioridad y puntuación.
audio-design
6,6 milEnseña a tu agente la mezcla de audio de juegos: buses, volumen en decibelios, ducking bajo los diálogos, música adaptativa y variación de efectos de sonido.
camera-systems
6,6 milAyuda a tu agente a crear cámaras de juego que siguen con suavidad, se mantienen dentro del nivel y orbitan o miran alrededor en 3D.
Skills parecidas
diffs
394 milPermite que tu agente genere un diff real y compartible de los cambios, como enlace de visualización o archivo de imagen, en lugar de un resumen escrito a mano.
coding-agent
394 milAyuda a tu agente a pasar un trabajo de programación grande a Codex, Claude Code u OpenCode como trabajador en segundo plano, y después revisar su progreso.
gh-issues
394 milAyuda a tu agente a encontrar incidencias de GitHub, elegir cuáles trabajar y abrir pull requests con correcciones, incluido el seguimiento de los comentarios de revisión.