mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
only normalize movement if len >= 1
This commit is contained in:
parent
3593fcd4d5
commit
63b4091ddd
|
@ -42,7 +42,7 @@ fn update_movement(
|
||||||
dt: UniqueView<DeltaTime>,
|
dt: UniqueView<DeltaTime>,
|
||||||
) {
|
) {
|
||||||
if inputs.movement == Vec2::ZERO { return }
|
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() {
|
for (_, mut transform) in (&controllers, &mut transforms).iter() {
|
||||||
let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation();
|
let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation();
|
||||||
translation += (rotation * Vec3::NEG_Z).normalize() * movement.y;
|
translation += (rotation * Vec3::NEG_Z).normalize() * movement.y;
|
||||||
|
|
|
@ -111,7 +111,9 @@ fn update_input_state_gamepad (
|
||||||
fn input_end(
|
fn input_end(
|
||||||
mut inputs: UniqueViewMut<Inputs>,
|
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 (
|
pub fn init_input (
|
||||||
|
|
Loading…
Reference in a new issue