Skip to content

Commit

Permalink
made Plugin runs after bevy input systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Threadzless committed Dec 12, 2023
1 parent c29daac commit 5d9479b
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(First, (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 5d9479b

Please sign in to comment.