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 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. The bevy 0.20.0 crate page includes bevy_state in the default_app collection. The state module was opened; App installation method names were not. Do not invent init_state or similar.
  • Per-entity mode. Store an enum in a Component and branch in a system (Query from the ECS page). No per-entity state-machine type was opened.

Coming from Godot

Installs
4
GitHub Stars
850
First Seen
3 days ago