only normalize movement if len >= 1

This commit is contained in:
griffi-gh 2023-02-01 23:46:40 +01:00
parent 3593fcd4d5
commit 63b4091ddd
2 changed files with 4 additions and 2 deletions

View file

@ -42,7 +42,7 @@ fn update_movement(
dt: UniqueView<DeltaTime>,
) {
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;

View file

@ -111,7 +111,9 @@ fn update_input_state_gamepad (
fn input_end(
mut inputs: UniqueViewMut<Inputs>,
) {
inputs.movement = inputs.movement.normalize_or_zero();
if inputs.movement.length() >= 1. {
inputs.movement = inputs.movement.normalize();
}
}
pub fn init_input (