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.
This commit is contained in:
@@ -120,13 +120,13 @@ fn turn_if_edge(
|
||||
fn check_keyboard(
|
||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
|
||||
mut query: Query<&mut Velocity, With<PlayerBoid>>,
|
||||
mut query: Query<&mut Force, With<PlayerBoid>>,
|
||||
) {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user