-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Milestone
Description
Bevy version : 0.10 on Win10-64
What you did
I'm starting learning new states in Bevy. I tried the following code, assuming that when using 2 states, I could manage both when defining set and scheduling :
use bevy::prelude::*;
#[derive(States, Debug, Clone, Copy, Eq, PartialEq, Hash, Default)]
enum AppState {
#[default]
MainMenu,
InGame,
}
#[derive(States, Debug, Clone, Copy, Eq, PartialEq, Hash, Default)]
enum SimulationState {
Running,
#[default]
Paused,
}
#[test]
fn test_multiple_states() {
let mut app = App::new();
app.add_state::<AppState>()
.add_state::<SimulationState>()
.add_system(
spawn_pause_menu
.in_set(OnUpdate(AppState::InGame))
.in_schedule(OnEnter(SimulationState::Paused)),
)
.run();
fn spawn_pause_menu(mut _commands: Commands) {
panic!("Pause menu spawned");
}
}What went wrong
Here, the test failed, because the pause menu was spawn but the AppState is not InGame, but MainMenu. I suppose that the spawn_pause_menu is called because it entered SimulationState::Paused, not checking the in_set(OnUpdate(AppState::InGame)). Is that expected? If the answer is yes, I would like an explanation on how should I manage this case.
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior