misc
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::f32::EPSILON;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy::{input::mouse::MouseMotion, prelude::*};
|
||||
use bevy_rapier3d::prelude::*;
|
||||
|
||||
use crate::{
|
||||
@@ -8,14 +8,14 @@ use crate::{
|
||||
player::{GravityDirection, JumpSpeed, MoveSpeed, PlayerDrag, PlayerForce, PlayerMotion, PlayerVelocity},
|
||||
tags::Player,
|
||||
},
|
||||
utils::rotation::get_alignment_rotation,
|
||||
utils::{input::get_mouse_delta, rotation::get_alignment_rotation},
|
||||
};
|
||||
|
||||
pub struct PlayerPlugin;
|
||||
|
||||
impl Plugin for PlayerPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(PreUpdate, keyboard_input.in_set(PlayerInputSystems));
|
||||
app.add_systems(PreUpdate, (keyboard_input).in_set(PlayerInputSystems));
|
||||
app.add_systems(Update, (apply_gravity, apply_forces, apply_motion, apply_drag).chain());
|
||||
app.add_systems(Update, align_with_gravity);
|
||||
}
|
||||
@@ -124,6 +124,11 @@ fn keyboard_input(
|
||||
// controller.translation = Some(move_vec * time.delta_secs());
|
||||
}
|
||||
|
||||
fn player_look(mut player: Single<&mut Transform, With<Player>>, mouse_motion: EventReader<MouseMotion>) {
|
||||
let delta = get_mouse_delta(mouse_motion);
|
||||
player.rotate_y(delta.x);
|
||||
}
|
||||
|
||||
fn align_with_gravity(
|
||||
player: Single<
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user