From a2b5f66ef584b4a07e759a15be1d5b99a719c659 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Fri, 31 Oct 2025 20:37:41 +0100 Subject: [PATCH 1/7] Expose default timestep --- crates/bevy_time/src/fixed.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_time/src/fixed.rs b/crates/bevy_time/src/fixed.rs index f1c67ea4a0ca9..607595f67890f 100644 --- a/crates/bevy_time/src/fixed.rs +++ b/crates/bevy_time/src/fixed.rs @@ -10,7 +10,7 @@ use crate::{time::Time, virt::Virtual}; /// /// A specialization of the [`Time`] structure. **For method documentation, see /// [`Time#impl-Time`].** -/// +/// /// It is automatically inserted as a resource by /// [`TimePlugin`](crate::TimePlugin) and updated based on /// [`Time`](Virtual). The fixed clock is automatically set as the @@ -22,7 +22,7 @@ use crate::{time::Time, virt::Virtual}; /// consistent behavior, regardless of framerate. /// /// The default [`timestep()`](Time::timestep) is 64 hertz, or 15625 -/// microseconds. This value was chosen because using 60 hertz has the potential +/// microseconds, see [`Time::DEFAULT_TIMESTEP`]. This value was chosen because using 60 hertz has the potential /// for a pathological interaction with the monitor refresh rate where the game /// alternates between running two fixed timesteps and zero fixed timesteps per /// frame (for example when running two fixed timesteps takes longer than a @@ -73,7 +73,7 @@ pub struct Fixed { impl Time { /// Corresponds to 64 Hz. - const DEFAULT_TIMESTEP: Duration = Duration::from_micros(15625); + pub const DEFAULT_TIMESTEP: Duration = Duration::from_micros(15625); /// Return new fixed time clock with given timestep as [`Duration`] /// From f5fdcbd21218238825c7f27d3ad884212317e9b7 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Fri, 31 Oct 2025 20:48:24 +0100 Subject: [PATCH 2/7] Add TimeUpdateStrategy::FixedTimestep --- crates/bevy_time/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index 3d515597ac6e8..bd6e0faf98c1e 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -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. + /// This means that a call to [`App::update`] will always run the fixed loop exactly once. + FixedTimestep, } /// Channel resource used to receive time from the render world. @@ -144,6 +147,7 @@ pub fn create_time_channels() -> (TimeSender, TimeReceiver) { pub fn time_system( mut real_time: ResMut>, mut virtual_time: ResMut>, + fixed_time: Res>, mut time: ResMut