Zero out velocity when Speed
component is removed.
This commit is contained in:
parent
056a96f7fc
commit
60ad00276e
|
@ -202,6 +202,14 @@ fn speak_direction(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_speed(removed: RemovedComponents<Speed>, mut query: Query<&mut RigidBodyVelocity>) {
|
||||||
|
for entity in removed.iter() {
|
||||||
|
if let Ok(mut velocity) = query.get_mut(entity) {
|
||||||
|
velocity.linvel = Vec2::ZERO.into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct NavigationConfig<S, A> {
|
pub struct NavigationConfig<S, A> {
|
||||||
pub action_backward: Option<A>,
|
pub action_backward: Option<A>,
|
||||||
|
@ -264,7 +272,8 @@ where
|
||||||
.register_type::<RotationSpeed>()
|
.register_type::<RotationSpeed>()
|
||||||
.register_type::<Sprinting>()
|
.register_type::<Sprinting>()
|
||||||
.add_system(update_direction.system())
|
.add_system(update_direction.system())
|
||||||
.add_system(speak_direction.system().chain(error_handler.system()));
|
.add_system(speak_direction.system().chain(error_handler.system()))
|
||||||
|
.add_system_to_stage(CoreStage::PostUpdate, remove_speed.system());
|
||||||
if config.movement_control_states.is_empty() {
|
if config.movement_control_states.is_empty() {
|
||||||
app.add_system(movement_controls::<S, A>.system());
|
app.add_system(movement_controls::<S, A>.system());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user