misc
This commit is contained in:
4
rustfmt.toml
Normal file
4
rustfmt.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
hard_tabs = true
|
||||||
|
max_width = 120
|
||||||
|
brace_style = "AlwaysNextLine"
|
||||||
|
control_brace_style = "AlwaysNextLine"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::f32::EPSILON;
|
use std::f32::EPSILON;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::{input::mouse::MouseMotion, prelude::*};
|
||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -8,14 +8,14 @@ use crate::{
|
|||||||
player::{GravityDirection, JumpSpeed, MoveSpeed, PlayerDrag, PlayerForce, PlayerMotion, PlayerVelocity},
|
player::{GravityDirection, JumpSpeed, MoveSpeed, PlayerDrag, PlayerForce, PlayerMotion, PlayerVelocity},
|
||||||
tags::Player,
|
tags::Player,
|
||||||
},
|
},
|
||||||
utils::rotation::get_alignment_rotation,
|
utils::{input::get_mouse_delta, rotation::get_alignment_rotation},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlayerPlugin;
|
pub struct PlayerPlugin;
|
||||||
|
|
||||||
impl Plugin for PlayerPlugin {
|
impl Plugin for PlayerPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
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, (apply_gravity, apply_forces, apply_motion, apply_drag).chain());
|
||||||
app.add_systems(Update, align_with_gravity);
|
app.add_systems(Update, align_with_gravity);
|
||||||
}
|
}
|
||||||
@@ -124,6 +124,11 @@ fn keyboard_input(
|
|||||||
// controller.translation = Some(move_vec * time.delta_secs());
|
// 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(
|
fn align_with_gravity(
|
||||||
player: Single<
|
player: Single<
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user