Skip to content

computed_states example broken #22822

@scottgshannon

Description

@scottgshannon

Bevy version and features

  • 0.18.0
  • bevy_dev_tools

What you did

While running the computed_states example, pausing or activating the turbo causes a duplicate sprite to be produced.

What went wrong

State transitions for ComputedStates are not idempotent and will trigger OnEnter schedules per underlying state change without their corresponding OnExit schedules.

The provided example for ComputedStates will rerun the setup_game system and produce an additional sprite per pause or turbo switch.

Additional information

The behavior change occured on Pull Request #21792

On crates/bevy_state/src/state/computed_states.rs:79
/// Whether state transition schedules should be run when the state changes to the same value. Default istrue. const ALLOW_SAME_STATE_TRANSITIONS: bool = true;
Setting the flag to false returns the example to 0.17.0 behavior.

I'm very new to Bevy, so I'm unsure if this should be considered a bug in Bevy or an example that needs updated to meet new behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-StatesApp-level states machinesC-BugAn unexpected or incorrect behaviorC-ExamplesAn addition or correction to our examplesD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesP-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions