| Crates.io | bevy_gearbox |
| lib.rs | bevy_gearbox |
| version | 0.4.0 |
| created_at | 2025-06-03 17:21:33.10226+00 |
| updated_at | 2025-10-02 00:21:59.687588+00 |
| description | State machine system for the bevy game engine |
| homepage | https://github.com/DEMIURGE-studio/bevy_gearbox |
| repository | https://github.com/DEMIURGE-studio/bevy_gearbox |
| max_upload_size | |
| id | 1699322 |
| size | 263,629 |
Statecharts for Bevy, designed for ECS-first workflows and data-driven tools. Pairs well with the visual editor bevy_gearbox_editor.
bevy_gearbox provides a state machine runtime modeled after XState’s core ideas (LCA-based transitions, entry/exit/transition phases, eventless transitions), adapted to Bevy’s ECS. It’s not a perfect logical match to XState; it prioritizes Bevy ergonomics, serialization, and editor integration.
bevy_gearbox_editor for rapid iteration and live statechart inspection.StateChildOf / StateChildren.EdgeKind::Internal to suppress re-entry.Source(Entity), Target(Entity), EdgeKind.EventEdge<E> components on edges.AlwaysEdge.After { duration } with cancellation on exit.Logic tree.TransitionActions emitted between exits and entries.app.add_plugins(GearboxPlugin)
.add_observer(edge_event_listener::<YourEvent>);
commands.trigger_targets(YourEvent, machine_root);
Source, Target, EdgeKind, EventEdge<E>, AlwaysEdge, After.bevy_gearbox_editor.When manually building state machines through commands it is important to add the StateMachine component to your root last. This initializes the machine, and if you don't add the StateMachine to the root after you've added all your InitialState components to other state entities, it will not initialize correctly. The proper "layout" for building statechart entities is demonstrated in the repeater example. This is not a problem if you use a scene to spawn your statechart. You can author statechart scenes using the editor. In the future this will be solved by building state machines through bsn.
| Crate | Version | Bevy |
|---|---|---|
| bevy_gearbox/editor | 0.3.4 | 0.17 |
| bevy_gearbox | 0.3.3 | 0.16 |
| bevy_gearbox_editor | 0.3.3 | 0.16 |
Dual-licensed under MIT or Apache-2.0, at your option.