Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_time/src/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{time::Time, virt::Virtual};
///
/// A specialization of the [`Time`] structure. **For method documentation, see
/// [`Time<Fixed>#impl-Time<Fixed>`].**
///
///
/// It is automatically inserted as a resource by
/// [`TimePlugin`](crate::TimePlugin) and updated based on
/// [`Time<Virtual>`](Virtual). The fixed clock is automatically set as the
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ pub enum TimeUpdateStrategy {
ManualInstant(Instant),
/// [`Time`] will be incremented by the specified [`Duration`] each frame.
ManualDuration(Duration),
/// [`Time`] will be incremented by the fixed timestep each frame, multiplied by the specified factor `n`.
/// This means that a call to [`App::update`] will always run the fixed loop exactly n times.
FixedTimesteps(u32),
}

/// Channel resource used to receive time from the render world.
Expand All @@ -144,6 +147,7 @@ pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
pub fn time_system(
mut real_time: ResMut<Time<Real>>,
mut virtual_time: ResMut<Time<Virtual>>,
fixed_time: Res<Time<Fixed>>,
mut time: ResMut<Time>,
update_strategy: Res<TimeUpdateStrategy>,
#[cfg(feature = "std")] time_recv: Option<Res<TimeReceiver>>,
Expand Down Expand Up @@ -175,6 +179,9 @@ pub fn time_system(
}
TimeUpdateStrategy::ManualInstant(instant) => real_time.update_with_instant(*instant),
TimeUpdateStrategy::ManualDuration(duration) => real_time.update_with_duration(*duration),
TimeUpdateStrategy::FixedTimesteps(factor) => {
real_time.update_with_duration(fixed_time.timestep() * *factor);
}
}

update_virtual_time(&mut time, &mut virtual_time, &real_time);
Expand Down