diff --git a/.vscode/launch.json b/.vscode/launch.json index 1d4bc77..a3aa1ff 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,14 @@ "name": "Build and Run program", "request": "launch", "type": "node-terminal" - } + }, + { + "command": "nix-shell --run 'cargo run --features bevy/dynamic_linking'", + "name": "Mold build and run program", + "request": "launch", + "type": "node-terminal" + }, + ], "compounds": [] } diff --git a/Cargo.lock b/Cargo.lock index 4b13e5f..7260eac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,7 +313,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea370412c322af887c9115442d8f2ec991b652f163a1d8920ecaf08cae63f2bc" dependencies = [ - "bevy_dylib", "bevy_internal", ] diff --git a/Cargo.toml b/Cargo.toml index 15e63d8..e9b448c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ opt-level = 3 [dependencies] -bevy = { version = "0.13.1", features = ["wayland", "dynamic_linking"]} +bevy = { version = "0.13.1", features = ["wayland"]} bevy_dylib = "0.13.1" bevy_editor_pls = "0.8.1" bevy_xpbd_3d = {git = "https://git.opencodebox.com/MikolajG/bevy_xpbd", branch = "reflect-serialize"} diff --git a/src/charcacter_controller.rs b/src/charcacter_controller.rs index 8d9a3e0..08eb138 100644 --- a/src/charcacter_controller.rs +++ b/src/charcacter_controller.rs @@ -23,11 +23,11 @@ pub struct CharacterControllerPlugin; impl Plugin for CharacterControllerPlugin{ fn build(&self, app: &mut App) { app.add_systems(Update,( - update_grounded, keyboard_input, - move_character, - dampen_movement) + ) ); + app.add_systems(FixedUpdate, (move_character, + dampen_movement,update_grounded)); app.add_event::(); } } @@ -164,16 +164,16 @@ pub fn move_character( let angle = rotation.rotate(-hit.normal2).angle_between(Vector::Y).abs(); if angle <= character_controller.max_slope_angle { slope_factor *= (angle / character_controller.max_slope_angle).cos(); + velocity.x += direction.x * character_controller.movement_acceleration * slope_factor * delta_time; + velocity.z -= direction.y * character_controller.movement_acceleration * slope_factor * delta_time; } else { velocity.x = 0.0; velocity.z = 0.0; } } - velocity.x += direction.x * character_controller.movement_acceleration * delta_time * slope_factor; - velocity.z -= direction.y * character_controller.movement_acceleration * delta_time * slope_factor; } else { - velocity.x += direction.x * character_controller.movement_acceleration * delta_time * character_controller.air_control_factor; - velocity.z -= direction.y * character_controller.movement_acceleration * delta_time * character_controller.air_control_factor; + velocity.x += direction.x * character_controller.movement_acceleration * character_controller.air_control_factor * delta_time ; + velocity.z -= direction.y * character_controller.movement_acceleration * character_controller.air_control_factor * delta_time ; } } MovementAction::Jump => { diff --git a/src/main.rs b/src/main.rs index 9042424..a135f8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -use bevy::prelude::*; +use bevy::{diagnostic::FrameTimeDiagnosticsPlugin, prelude::*, window::Cursor}; use bevy_xpbd_3d::prelude::*; use bevy_editor_pls::prelude::*; mod charcacter_controller; @@ -26,9 +26,20 @@ fn main() { app .add_plugins(( - DefaultPlugins, + DefaultPlugins.set(WindowPlugin { + primary_window: Some(Window { + cursor: Cursor::default(), + present_mode: bevy::window::PresentMode::AutoNoVsync, + mode: bevy::window::WindowMode::Windowed, + title: "Trouble in Terror Town: Community Edition".to_string(), + resizable: true, + ..default() + }), + ..default() + }), PhysicsPlugins::default(), EditorPlugin::default(), + FrameTimeDiagnosticsPlugin::default(), CharacterControllerPlugin, )) .add_systems(Startup, setup)