use std::f32::consts::FRAC_PI_2; use bevy::{input::mouse::MouseMotion, prelude::*}; use bevy_rapier3d::prelude::*; use crate::{ components::{ camera::CameraPitch, player::{GravityDirection, JumpSpeed, MoveSpeed, PlayerDrag, PlayerForce, PlayerMotion, PlayerVelocity}, tags::Player, }, states::{input::InputWorldSystems, play::PlaySystems}, utils::{input::get_mouse_delta, rotation::get_alignment_rotation_preserve_twist}, }; pub struct PlayerPlugin; impl Plugin for PlayerPlugin { fn build(&self, app: &mut App) { app.add_systems(PreUpdate, (keyboard_input, player_look).in_set(InputWorldSystems)); app.add_systems( Update, (apply_gravity, apply_forces, apply_motion, apply_drag) .chain() .in_set(PlaySystems), ); app.add_systems(Update, align_with_gravity.in_set(PlaySystems)); } } fn apply_forces(player: Single<(&mut PlayerVelocity, &PlayerForce), With>, time: Res