From 3fc9144fbec0f7684bfc6320e54e996c45634324 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Fri, 11 Jul 2025 20:39:58 +0200 Subject: [PATCH] Add comment --- examples/movement/physics_in_fixed_timestep.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/movement/physics_in_fixed_timestep.rs b/examples/movement/physics_in_fixed_timestep.rs index d5c53b9212..dab434ab9c 100644 --- a/examples/movement/physics_in_fixed_timestep.rs +++ b/examples/movement/physics_in_fixed_timestep.rs @@ -282,6 +282,9 @@ impl Default for CameraSensitivity { /// /// There are many strategies for how to handle all the input that happened since the last fixed timestep. /// This is a very simple one: we just use the last available input. +/// That strategy works fine for us since the user continuously presses the input keys in this example. +/// If we had some kind of instantaneous action like jumping, we would need to remember that that input +/// was pressed at some point since the last fixed timestep. fn accumulate_input( keyboard_input: Res>, player: Single<(&mut AccumulatedInput, &mut Velocity)>, @@ -291,6 +294,8 @@ fn accumulate_input( /// Note that about 1.5 is the average walking speed of a human. const SPEED: f32 = 4.0; let (mut input, mut velocity) = player.into_inner(); + // Reset the input to zero before reading the new input. As mentioned above, we can only do this + // because this is continuously pressed by the user. Do not reset e.g. whether the user wants to jump here. input.0 = Vec2::ZERO; if keyboard_input.pressed(KeyCode::KeyW) { input.y += 1.0;