bevy-state-machines
Installation
SKILL.md
Bevy state machines
When to use
Load this when the app needs a large-scale mode (paused, in a menu, loading) or when one entity needs a small mode flag. Use bevy::state for the first. Use a component for the second. Do not merge them into one Godot-style state graph.
ECS shape
- App states.
bevy::state: states are app-wide finite state machines. Three types implementStates.- Standard states change only by setting the
NextState<S>resource. SubStatesalso useNextState<S>, and are removed from theWorldwhen source states are not in the required state.ComputedStatesderive from other states through acomputemethod.
- Standard states change only by setting the
- Transition schedules.
OnEnter<S>,OnExit<S>, andOnTransition<S>run systems on matching transitions.StateTransitionEvent<S>fires when stateSchanges. Run conditions:in_state<S>andstate_changed<S>. - Entity lifetime.
DespawnOnEnter<S>andDespawnOnExit<S>despawn entities on those transitions (state_scoped). - Feature. The
bevy0.20.0 crate page includesbevy_statein thedefault_appcollection. The state module was opened;Appinstallation method names were not. Do not inventinit_stateor similar. - Per-entity mode. Store an enum in a
Componentand branch in a system (Queryfrom the ECS page). No per-entity state-machine type was opened.