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. Keep those two owners separate.

ECS shape

  • App states. bevy::state: states are app-wide finite state machines. Three types implement States.
    • Standard states change only by setting the NextState<S> resource.
    • SubStates also use NextState<S>, and are removed from the World when source states are not in the required state.
    • ComputedStates derive from other states through a compute method.
  • Transition schedules. OnEnter<S>, OnExit<S>, and OnTransition<S> run systems on matching transitions. StateTransitionEvent<S> fires when state S changes. Run conditions: in_state<S> and state_changed<S>.
  • Entity lifetime. DespawnOnEnter<S> and DespawnOnExit<S> despawn entities on those transitions (state_scoped).
  • Feature. bevy_state ships in the default bevy app plugins. Install a state with init_state.
  • Per-entity mode. Store an enum in a Component and branch in a system. That enum is not a States type.
Installs
15
GitHub Stars
889
First Seen
Oct 11, 2026