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 actions.pressed(NavigationAction::Move) {
|
||||||
if let Some(pair) = actions.clamped_axis_pair(NavigationAction::Move) {
|
if let Some(pair) = actions.clamped_axis_pair(NavigationAction::Move) {
|
||||||
cleanup = true;
|
cleanup = true;
|
||||||
let direction = pair.xy();
|
let mut direction = pair.xy();
|
||||||
let forward_backward_movement_factor = if direction.x > 0. {
|
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
|
config.forward_movement_factor
|
||||||
} else if direction.x < 0. {
|
} else if direction.y < 0. {
|
||||||
config.backward_movement_factor
|
config.backward_movement_factor
|
||||||
} else {
|
} else {
|
||||||
0.
|
0.
|
||||||
|
@ -93,7 +99,7 @@ fn movement_controls<State>(
|
||||||
config
|
config
|
||||||
.strafe_movement_factor
|
.strafe_movement_factor
|
||||||
.min(forward_backward_movement_factor)
|
.min(forward_backward_movement_factor)
|
||||||
} else if direction.y != 0. {
|
} else if direction.x != 0. {
|
||||||
config.strafe_movement_factor
|
config.strafe_movement_factor
|
||||||
} else {
|
} else {
|
||||||
forward_backward_movement_factor
|
forward_backward_movement_factor
|
||||||
|
@ -102,6 +108,7 @@ fn movement_controls<State>(
|
||||||
s *= movement_factor;
|
s *= movement_factor;
|
||||||
**speed = s;
|
**speed = s;
|
||||||
let mut v = direction * **speed;
|
let mut v = direction * **speed;
|
||||||
|
v = Vec2::new(v.y, -v.x);
|
||||||
v = transform
|
v = transform
|
||||||
.compute_matrix()
|
.compute_matrix()
|
||||||
.transform_vector3(v.extend(0.))
|
.transform_vector3(v.extend(0.))
|
||||||
|
@ -132,7 +139,7 @@ fn movement_controls<State>(
|
||||||
if actions.pressed(NavigationAction::Rotate) {
|
if actions.pressed(NavigationAction::Rotate) {
|
||||||
cleanup = true;
|
cleanup = true;
|
||||||
let delta =
|
let delta =
|
||||||
rotation_speed.radians() * actions.clamped_value(NavigationAction::Rotate);
|
-rotation_speed.radians() * actions.clamped_value(NavigationAction::Rotate);
|
||||||
actions.press(NavigationAction::SetAngularVelocity);
|
actions.press(NavigationAction::SetAngularVelocity);
|
||||||
actions
|
actions
|
||||||
.action_data_mut(NavigationAction::SetAngularVelocity)
|
.action_data_mut(NavigationAction::SetAngularVelocity)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user