Module bevy::time::fixed_timestep

Expand description

Tools to run systems at a regular interval. This can be extremely useful for steady, frame-rate independent gameplay logic and physics.

To run a system on a fixed timestep, add it to the CoreSchedule::FixedUpdate Schedule. This schedules is run in the CoreSet::FixedUpdate near the start of each frame, via the run_fixed_update_schedule exclusive system.

This schedule will be run a number of times each frame, equal to the accumulated divided by the period resource, rounded down, as tracked in the FixedTime resource. Unused time will be carried over.

This does not guarantee that the time elapsed between executions is exact, and systems in this schedule can run 0, 1 or more times on any given frame.

For example, a system with a fixed timestep run criteria of 120 times per second will run two times during a ~16.667ms frame, once during a ~8.333ms frame, and once every two frames with ~4.167ms frames. However, the same criteria may not result in exactly 8.333ms passing between each execution.

When using fixed time steps, it is advised not to rely on Time::delta or any of it’s variants for game simulation, but rather use the value of FixedTime instead.

Structs

  • The amount of time that must pass before the fixed timestep schedule is run again.

Enums

Functions