Skip to content

Result::unwrap() on an Err value: StateAlreadyQueued' #5552

Description

@GetAGripGal

Bevy version

0.8

Relevant system information

OS: Windows 11

What you did

I attempted to set change my gamestate like so:

// Change the state
if *state.current() != event.0 {
    state.set(event.0).unwrap();
}

What went wrong

Doing so crashes the game with the following error:
Result::unwrap()` on an `Err` value: StateAlreadyQueued'

Additional information

The current workaround i took was to use State::overwrite_set instead like so:

// Change the state
if *state.current() != event.0 {
    // Using [`State::overwrite_set`] instead of [`State::set`] to cirvumvent the 'Aleady Scheduled' bug. 
    state.overwrite_set(event.0).unwrap();
}

Edit: To clarify, this system is only being called once per frame and the state isn't currently being changed anywhere else in the code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions