diff --git a/src/navigation.rs b/src/navigation.rs index 0ff6d99..d8d94db 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -202,6 +202,14 @@ fn speak_direction( Ok(()) } +fn remove_speed(removed: RemovedComponents, 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)] pub struct NavigationConfig { pub action_backward: Option, @@ -264,7 +272,8 @@ where .register_type::() .register_type::() .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() { app.add_system(movement_controls::.system()); } else {