Skip to content

Adding a state lets unrelated systems run twice after system sets v2 #1753

Closed
@jakobhellermann

Description

@jakobhellermann

When adding a state after #1675 systems in the same stage get run twice.

use bevy::{app::ScheduleRunnerSettings, prelude::*};
use std::time::Duration;

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
enum AppState { Main }

fn main() {
    App::build()
        .insert_resource(ScheduleRunnerSettings::run_loop(Duration::from_secs_f32(1.0 / 60.0)))
        .add_plugins(MinimalPlugins)
        .add_state(AppState::Main)
        .add_system(system.system())
        .run();
}

fn system() {
    println!("<user system runs>");
}

results in the following execution

run stage First
run stage Startup
run stage PreUpdate
run stage Update
<user system runs>
<user system runs>
run stage PostUpdate
run stage Last

Removing the .add_state or reverting #1675 fixes the issue, i.e. the system gets run only once.

ping @Ratysz

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions