From 8b61d38636d6e81da7dc090ad1ac8b5bea214742 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Tue, 2 Sep 2025 16:08:18 -0500 Subject: [PATCH] Make keyboard control forces, not velocities The keyboard input should apply a force, not modify the velocity. Right now, there is no Mass component, but in the future there might be. I've just fixed a broken physics integrator made by bad assumptions, too, so I'm goig to do this for consistency if nothing else. --- src/birdoids/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/birdoids/mod.rs b/src/birdoids/mod.rs index 094b3d08..482c6454 100644 --- a/src/birdoids/mod.rs +++ b/src/birdoids/mod.rs @@ -120,13 +120,13 @@ fn turn_if_edge( fn check_keyboard( keyboard_input: Res>, mut app_exit_events: ResMut>, - mut query: Query<&mut Velocity, With>, + mut query: Query<&mut Force, With>, ) { if keyboard_input.just_pressed(KeyCode::KeyQ) { app_exit_events.send(bevy::app::AppExit::Success); } - let mut pvelocity = query + let mut impulse = query .single_mut() .expect("[birdoids_plugin::check_keyboard()] ->> There seems to be more than one player... How did that happen?"); let mut dir = Vec2::ZERO; @@ -143,7 +143,7 @@ fn check_keyboard( dir.y += 1.0; } - **pvelocity += dir.extend(0.0); + **impulse += dir.extend(0.0) * 50.0; } fn cohesion(