Skip to content

State can't be used in two stages at once (even with get_driver) #1865

@concave-sphere

Description

@concave-sphere

Bevy version

0.5

Operating system & version

Debian GNU/Linux "buster"

What you did

  1. Invoke app.add_state(MyState::StateOne)
  2. Create a stage MyStage
  3. Invoke app.add_system_set(State::<MyState>::get_driver())
  4. Add some systems to MyStage via SystemSet::on_update(MyState::StateOne), etc.
  5. Add a system that switches between states.

What you expected to happen

Systems that trigger on state enter and exit should run when the state changes, regardless of stage.

What actually happened

Only state change systems in the Update stage are executed.

I know that the program hasn't completely locked because if I put state change systems into Update, they work fine. It does lock if I don't add State::<MyState>::get_driver(), so that's having an effect.

This text in the Bevy Rustdoc made me think this is supposed to work:

If you need to use your state in a different stage, consider using Self::add_state_to_stage or manually adding State::get_driver to additional stages you need it in.

Additional information

Sample code:
test.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorS-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be merged

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions