14 releases

Uses new Rust 2024

new 0.16.0-rc.1 Mar 18, 2025
0.15.1 Jan 3, 2025
0.15.0 Nov 29, 2024
0.14.0 Jul 4, 2024

#2912 in Game dev

Download history 11917/week @ 2024-12-02 9850/week @ 2024-12-09 9439/week @ 2024-12-16 6095/week @ 2024-12-23 8569/week @ 2024-12-30 11492/week @ 2025-01-06 11955/week @ 2025-01-13 10866/week @ 2025-01-20 8791/week @ 2025-01-27 12403/week @ 2025-02-03 11562/week @ 2025-02-10 10138/week @ 2025-02-17 14528/week @ 2025-02-24 11921/week @ 2025-03-03 13993/week @ 2025-03-10 11610/week @ 2025-03-17

53,691 downloads per month
Used in 151 crates (15 directly)

MIT/Apache

4.5MB
80K SLoC

In Bevy, states are app-wide interdependent, finite state machines that are generally used to model the large scale structure of your program: whether a game is paused, if the player is in combat, if assets are loaded and so on.

This module provides 3 distinct types of state, all of which implement the States trait:

  • Standard States can only be changed by manually setting the NextState<S> resource. These states are the baseline on which the other state types are built, and can be used on their own for many simple patterns. See the states example for a simple use case.
  • SubStates are children of other states - they can be changed manually using NextState<S>, but are removed from the World if the source states aren't in the right state. See the sub_states example for a simple use case based on the derive macro, or read the trait docs for more complex scenarios.
  • ComputedStates are fully derived from other states - they provide a compute method that takes in the source states and returns their derived value. They are particularly useful for situations where a simplified view of the source states is necessary - such as having an InAMenu computed state, derived from a source state that defines multiple distinct menus. See the computed state example to see usage samples for these states.

Most of the utilities around state involve running systems during transitions between states, or determining whether to run certain systems, though they can be used more directly as well. This makes it easier to transition between menus, add loading screens, pause games, and more.

Specifically, Bevy provides the following utilities:

Dependencies

~6–16MB
~228K SLoC