Zero out vectors instead of setting to None.

This commit is contained in:
Nolan Darilek 2023-05-09 08:43:31 -05:00
parent 4480b33555
commit 5a3ce9b790

View File

@ -217,7 +217,8 @@ fn controls(
trace!("{entity:?}: Stopped moving");
actions.release(NavigationAction::SetLinearVelocity);
actions.release(NavigationAction::Translate);
actions.action_data_mut(NavigationAction::Move).axis_pair = None;
actions.action_data_mut(NavigationAction::Move).axis_pair =
Some(DualAxisData::from_xy(Vec2::ZERO));
}
if actions.pressed(NavigationAction::SetLinearVelocity) {
if let Some(pair) = actions.axis_pair(NavigationAction::SetLinearVelocity) {
@ -232,7 +233,7 @@ fn controls(
velocity.linvel = Vec2::ZERO;
actions
.action_data_mut(NavigationAction::SetLinearVelocity)
.axis_pair = None;
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
}
if actions.pressed(NavigationAction::Translate) {
if let Some(pair) = actions.axis_pair(NavigationAction::Translate) {
@ -246,7 +247,7 @@ fn controls(
}
actions
.action_data_mut(NavigationAction::Translate)
.axis_pair = None;
.axis_pair = Some(DualAxisData::from_xy(Vec2::ZERO));
}
if !snap_timers.contains_key(&entity) {
if let Some(rotation_speed) = rotation_speed {