From 63b4091ddd60bfbcc61626a4d213905521fa86e7 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Wed, 1 Feb 2023 23:46:40 +0100 Subject: [PATCH] only normalize movement if len >= 1 --- kubi/src/fly_controller.rs | 2 +- kubi/src/input.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kubi/src/fly_controller.rs b/kubi/src/fly_controller.rs index 5b303f4..2822d2a 100644 --- a/kubi/src/fly_controller.rs +++ b/kubi/src/fly_controller.rs @@ -42,7 +42,7 @@ fn update_movement( dt: UniqueView, ) { if inputs.movement == Vec2::ZERO { return } - let movement = inputs.movement.normalize_or_zero() * 30. * dt.0.as_secs_f32(); + let movement = inputs.movement * 30. * dt.0.as_secs_f32(); for (_, mut transform) in (&controllers, &mut transforms).iter() { let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation(); translation += (rotation * Vec3::NEG_Z).normalize() * movement.y; diff --git a/kubi/src/input.rs b/kubi/src/input.rs index 3e763de..6b92835 100644 --- a/kubi/src/input.rs +++ b/kubi/src/input.rs @@ -111,7 +111,9 @@ fn update_input_state_gamepad ( fn input_end( mut inputs: UniqueViewMut, ) { - inputs.movement = inputs.movement.normalize_or_zero(); + if inputs.movement.length() >= 1. { + inputs.movement = inputs.movement.normalize(); + } } pub fn init_input (