Artificually implement some deadzones.
This commit is contained in:
parent
b1254d9029
commit
8eb5e0971f
|
@ -81,10 +81,16 @@ fn movement_controls<State>(
|
|||
if actions.pressed(NavigationAction::Move) {
|
||||
if let Some(pair) = actions.clamped_axis_pair(NavigationAction::Move) {
|
||||
cleanup = true;
|
||||
let direction = pair.xy();
|
||||
let forward_backward_movement_factor = if direction.x > 0. {
|
||||
let mut direction = pair.xy();
|
||||
if direction.x.abs() < 0.5 {
|
||||
direction.x = 0.;
|
||||
}
|
||||
if direction.y.abs() < 0.5 {
|
||||
direction.y = 0.;
|
||||
}
|
||||
let forward_backward_movement_factor = if direction.y > 0. {
|
||||
config.forward_movement_factor
|
||||
} else if direction.x < 0. {
|
||||
} else if direction.y < 0. {
|
||||
config.backward_movement_factor
|
||||
} else {
|
||||
0.
|
||||
|
@ -93,7 +99,7 @@ fn movement_controls<State>(
|
|||
config
|
||||
.strafe_movement_factor
|
||||
.min(forward_backward_movement_factor)
|
||||
} else if direction.y != 0. {
|
||||
} else if direction.x != 0. {
|
||||
config.strafe_movement_factor
|
||||
} else {
|
||||
forward_backward_movement_factor
|
||||
|
@ -102,6 +108,7 @@ fn movement_controls<State>(
|
|||
s *= movement_factor;
|
||||
**speed = s;
|
||||
let mut v = direction * **speed;
|
||||
v = Vec2::new(v.y, -v.x);
|
||||
v = transform
|
||||
.compute_matrix()
|
||||
.transform_vector3(v.extend(0.))
|
||||
|
@ -132,7 +139,7 @@ fn movement_controls<State>(
|
|||
if actions.pressed(NavigationAction::Rotate) {
|
||||
cleanup = true;
|
||||
let delta =
|
||||
rotation_speed.radians() * actions.clamped_value(NavigationAction::Rotate);
|
||||
-rotation_speed.radians() * actions.clamped_value(NavigationAction::Rotate);
|
||||
actions.press(NavigationAction::SetAngularVelocity);
|
||||
actions
|
||||
.action_data_mut(NavigationAction::SetAngularVelocity)
|
||||
|
|
Loading…
Reference in New Issue
Block a user