diff --git a/src/fly_controller.rs b/src/fly_controller.rs index 07e0010..a1f2a93 100644 --- a/src/fly_controller.rs +++ b/src/fly_controller.rs @@ -41,12 +41,12 @@ fn update_movement( inputs: UniqueView, dt: UniqueView, ) { - let movement = inputs.movement * 30. * dt.0.as_secs_f32(); - if movement == Vec2::ZERO { return } + if inputs.movement == Vec2::ZERO { return } + let movement = inputs.movement.normalize_or_zero() * 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) * movement.y; - translation += (rotation * Vec3::X) * movement.x; + translation += (rotation * Vec3::NEG_Z).normalize() * movement.y; + translation += (rotation * Vec3::X).normalize() * movement.x; transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation); } } diff --git a/src/world/raycast.rs b/src/world/raycast.rs index 3f2f407..733a197 100644 --- a/src/world/raycast.rs +++ b/src/world/raycast.rs @@ -59,7 +59,7 @@ pub fn update_raycasts( } for (transform, report) in (&transform, &mut raycast).iter() { let (_, rotation, position) = transform.0.to_scale_rotation_translation(); - let direction = rotation * Vec3::NEG_Z; + let direction = (rotation * Vec3::NEG_Z).normalize(); *report = LookingAtBlock(world.raycast(position, direction, Some(30.))); } }