Skip to content

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

@GetAGripGal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions