Bevy version
c78b76b
What you did
In my game, I have several screens which I can go through by clicking the mouse (with just_pressed on Input<MouseButton>). Each screen has its own state.
Very dumb example that reproduce my issue:
use bevy::prelude::*;
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_state(AppState::State1)
.add_system_set(SystemSet::on_enter(AppState::State1).with_system(enter_state.system()))
.add_system_set(SystemSet::on_update(AppState::State1).with_system(next_state.system()))
.add_system_set(SystemSet::on_enter(AppState::State2).with_system(enter_state.system()))
.add_system_set(SystemSet::on_update(AppState::State2).with_system(next_state.system()))
.run();
}
#[derive(Clone, Eq, PartialEq, Debug)]
enum AppState {
State1,
State2,
}
fn enter_state(state: Res<State<AppState>>) {
eprintln!("entering {:?}", state.current());
}
fn next_state(mut state: ResMut<State<AppState>>, mouse_button_input: Res<Input<MouseButton>>) {
if mouse_button_input.just_pressed(MouseButton::Left) {
match state.current() {
AppState::State1 => state.set_next(AppState::State2),
AppState::State2 => state.set_next(AppState::State1),
}
.unwrap();
}
}
What you expected to happen
One click to go from State1 to State2, then one click to go from State2 to State1.
What actually happened
On first click, it changes state in a loop and lock the game.
Additional information
Now that system set can rerun in same frame, input isn't reset between two passes so just_pressed is always true
Bevy version
c78b76b
What you did
In my game, I have several screens which I can go through by clicking the mouse (with
just_pressedonInput<MouseButton>). Each screen has its own state.Very dumb example that reproduce my issue:
What you expected to happen
One click to go from
State1toState2, then one click to go fromState2toState1.What actually happened
On first click, it changes state in a loop and lock the game.
Additional information
Now that system set can rerun in same frame, input isn't reset between two passes so
just_pressedis always true