Behavior trees forbevy_behavior
A game-agnostic behavior tree engine for Bevy with composable Selector / Sequence nodes, tick-based cooldown tracking, and observation traits so one tree can drive NPCs across many games.
Game-agnostic trees
BehaviorNode is generic over an Observation snapshot and an Action enum, so the same tree logic drives NPCs without game-specific coupling.
- Reused across — Minecraft, Bevy Isometric, Discord MUD, and Unity.
- Zero-dep core — pure Rust; the optional bevy feature adds ECS integration.
What it gives you
Features
Generic tree
BehaviorNode is generic over an Observation type and an Action type, so each game supplies its own snapshot and command enum.
Composite nodes
Selector and Sequence compose leaves into trees.
Cooldown tracking
BehaviorContext, CooldownState, and TickCooldown gate actions by tick, per-NPC and globally.
Observation traits
Positioned, Healthed, Aware, and Ticked let built-in leaves query an NPC's world without knowing the concrete struct.
Zero-dep core
Pure Rust by default; the optional bevy feature adds Resource / Component derives for in-ECS evaluation.
Questions
Frequently asked
What is the bevy_behavior crate?
bevy_behavior is a game-agnostic behavior tree engine for Bevy. It provides the core BehaviorNode trait, Selector and Sequence composite nodes, a tick-based cooldown system, and observation traits so the same tree logic can drive NPCs across Minecraft, Bevy Isometric, Discord MUD, and Unity.
How is a behavior tree parameterized?
The tree is generic over an Observation type (an immutable snapshot the NPC can see, implementing Positioned, Healthed, Aware, and Ticked) and an Action type (a game-defined command enum). A mutable BehaviorContext carries the current tick and cooldown handles per evaluation.
Does bevy_behavior require Bevy?
No. The core crate is pure Rust with zero framework dependency. Enabling the optional bevy feature adds Bevy Resource and Component derives for in-ECS tree evaluation.
