Skip to content

Commit

Permalink
Reschedule move systems to run after inputs (#24)
Browse files Browse the repository at this point in the history
* moved the systems to First in the schedule

* made Plugin runs after bevy input systems
  • Loading branch information
Threadzless authored Dec 23, 2023
1 parent 42a3fb0 commit 3ab0341
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,45 @@ use bevy::{
};
use bevy_rapier3d::prelude::*;

/// Manages the FPS controllers. Executes in `PreUpdate`, after bevy's internal
/// input processing is finished.
///
/// If you need a system in `PreUpdate` to execute after FPS Controller's systems,
/// Do it like so:
///
/// ```
/// # use bevy::prelude::*;
///
/// struct MyPlugin;
/// impl Plugin for MyPlugin {
/// fn build(&self, app: &mut App) {
/// app.add_systems(
/// PreUpdate,
/// (my_system).after( bevy_fps_controller::controller::fps_controller_render )
/// );
/// }
/// }
///
/// fn my_system() { }
/// ```
pub struct FpsControllerPlugin;

impl Plugin for FpsControllerPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Update, (fps_controller_input, fps_controller_look, fps_controller_move, fps_controller_render).chain());
use bevy::input::{ mouse, keyboard, gamepad, touch };

app.add_systems(
PreUpdate,
(fps_controller_input, fps_controller_look, fps_controller_move, fps_controller_render)
.chain()
.after( mouse::mouse_button_input_system )
.after( keyboard::keyboard_input_system )
.after( gamepad::gamepad_axis_event_system )
.after( gamepad::gamepad_button_event_system )
.after( gamepad::gamepad_connection_system )
.after( gamepad::gamepad_event_system )
.after( touch::touch_screen_input_system )
);
}
}

Expand Down

0 comments on commit 3ab0341

Please sign in to comment.