RunFixedMainLoopSystem

Type Alias RunFixedMainLoopSystem 

Source
pub type RunFixedMainLoopSystem = RunFixedMainLoopSystems;
👎Deprecated since 0.17.0: Renamed to RunFixedMainLoopSystems.
Expand description

Deprecated alias for RunFixedMainLoopSystems.

Aliased Type§

pub enum RunFixedMainLoopSystem {
    BeforeFixedMainLoop,
    FixedMainLoop,
    AfterFixedMainLoop,
}

Variants§

§

BeforeFixedMainLoop

Runs before the fixed update logic.

A good example of a system that fits here is camera movement, which needs to be updated in a variable timestep, as you want the camera to move with as much precision and updates as the frame rate allows. A physics system that needs to read the camera position and orientation, however, should run in the fixed update logic, as it needs to be deterministic and run at a fixed rate for better stability. Note that we are not placing the camera movement system in Update, as that would mean that the physics system already ran at that point.

§Example

App::new()
  .add_systems(
    RunFixedMainLoop,
    update_camera_rotation.in_set(RunFixedMainLoopSystems::BeforeFixedMainLoop))
  .add_systems(FixedUpdate, update_physics);
§

FixedMainLoop

Contains the fixed update logic. Runs FixedMain zero or more times based on delta of Time<Virtual> and Time::overstep.

Don’t place systems here, use FixedUpdate and friends instead. Use this system instead to order your systems to run specifically inbetween the fixed update logic and all other systems that run in RunFixedMainLoopSystems::BeforeFixedMainLoop or RunFixedMainLoopSystems::AfterFixedMainLoop.

§Example

App::new()
  .add_systems(FixedUpdate, update_physics)
  .add_systems(
    RunFixedMainLoop,
    (
      // This system will be called before all interpolation systems
      // that third-party plugins might add.
      prepare_for_interpolation
        .after(RunFixedMainLoopSystems::FixedMainLoop)
        .before(RunFixedMainLoopSystems::AfterFixedMainLoop),
    )
  );
§

AfterFixedMainLoop

Runs after the fixed update logic.

A good example of a system that fits here is a system that interpolates the transform of an entity between the last and current fixed update. See the fixed timestep example for more details.

§Example

App::new()
  .add_systems(FixedUpdate, update_physics)
  .add_systems(
    RunFixedMainLoop,
    interpolate_transforms.in_set(RunFixedMainLoopSystems::AfterFixedMainLoop));