mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 16:28:42 -06:00
normalize rotation in update_movement
This commit is contained in:
parent
a468e764c3
commit
47839c03aa
|
@ -45,8 +45,9 @@ fn update_movement(
|
||||||
let movement = inputs.movement * 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;
|
let rotation_norm = rotation.normalize();
|
||||||
translation += (rotation * Vec3::X).normalize() * movement.x;
|
translation += (rotation_norm * Vec3::NEG_Z).normalize() * movement.y;
|
||||||
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
|
translation += (rotation_norm * Vec3::X).normalize() * movement.x;
|
||||||
|
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation_norm, translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue