Skip to content
Discussion options

You must be logged in to vote

By calling add_state on your Bevy App you are doing two things:

  1. Tell Bevy a type (in your case called AppState) that is supposed to function as a State
  2. Pass the initial value of the State

This state will now be saved in a resource State<your type> which you can request in systems (what you called callbacks) to read/change.

You can call your State whatever you want and can have any number of values for it. You can even have multiple States with different types.

You tell the engine (in your case via state.set) to which value of a certain state you want to switch. This means that Bevy knows the next state and the previous one.

When changing a State: the engine will run all on_exit systems …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@caelia
Comment options

@caelia
Comment options

Answer selected by caelia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants