Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Aug 22, 2024
1 parent 93458f2 commit cc2ba61
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions examples/movement/physics_in_fixed_timestep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, (spawn_text, spawn_player))
// Advance the physics simulation using a fixed timestep.
.add_systems(FixedUpdate, advance_physics)
.add_systems(
// The `RunFixedMainLoop` schedule allows us to schedule systems to run before and after the fixed timestep loop.
Expand All @@ -96,8 +97,8 @@ fn main() {
// If we ran this in `FixedUpdate`, it would sometimes not register player input, as that schedule may run zero times per frame.
handle_input.in_set(RunFixedMainLoopSystem::BeforeFixedMainLoop),
// The player's visual representation needs to be updated after the physics simulation has been advanced.
// This could be run in `Update`, but if we run it here instead, the other systems in `Update`
// will we working with the `Transform` that will actually be shown on screen.
// This could be run in `Update`, but if we run it here instead, the systems in `Update`
// will be working with the `Transform` that will actually be shown on screen.
update_rendered_transform.in_set(RunFixedMainLoopSystem::AfterFixedMainLoop),
),
)
Expand Down Expand Up @@ -223,7 +224,7 @@ fn advance_physics(
current_physical_translation.0 += velocity.0 * fixed_time.delta_seconds();

// Reset the input accumulator, as we are currently consuming all input that happened since the last fixed timestep.
*input = AccumulatedInput::default();
input.0 = Vec2::ZERO;
}
}

Expand Down

0 comments on commit cc2ba61

Please sign in to comment.