@@ -12,8 +12,7 @@ use crate::{time::Time, virt::Virtual, FixedUpdate};
12
12
/// It is automatically inserted as a resource by
13
13
/// [`TimePlugin`](crate::TimePlugin) and updated based on
14
14
/// [`Time<Virtual>`](Virtual). The fixed clock is automatically set as the
15
- /// generic [`Time`] resource during [`FixedUpdate`](bevy_app::FixedUpdate)
16
- /// schedule processing.
15
+ /// generic [`Time`] resource during [`FixedUpdate`] schedule processing.
17
16
///
18
17
/// The fixed timestep clock advances in fixed-size increments, which is
19
18
/// extremely useful for writing logic (like physics) that should have
@@ -27,13 +26,12 @@ use crate::{time::Time, virt::Virtual, FixedUpdate};
27
26
/// frame). Additionally, the value is a power of two which losslessly converts
28
27
/// into [`f32`] and [`f64`].
29
28
///
30
- /// To run a system on a fixed timestep, add it to the
31
- /// [`FixedUpdate`](bevy_app::FixedUpdate) schedule. This schedule is run a
32
- /// number of times between [`PreUpdate`](bevy_app::PreUpdate) and
33
- /// [`Update`](bevy_app::Update) according to the accumulated
34
- /// [`overstep()`](Time::overstep) time divided by the
35
- /// [`timestep()`](Time::timestep). This means the schedule may run 0, 1 or more
36
- /// times during a single update (which typically corresponds to a rendered
29
+ /// To run a system on a fixed timestep, add it to the [`FixedUpdate`] schedule.
30
+ /// This schedule is run a number of times between
31
+ /// [`PreUpdate`](bevy_app::PreUpdate) and [`Update`](bevy_app::Update)
32
+ /// according to the accumulated [`overstep()`](Time::overstep) time divided by
33
+ /// the [`timestep()`](Time::timestep). This means the schedule may run 0, 1 or
34
+ /// more times during a single update (which typically corresponds to a rendered
37
35
/// frame).
38
36
///
39
37
/// `Time<Fixed>` and the generic [`Time`] resource will report a
@@ -45,21 +43,20 @@ use crate::{time::Time, virt::Virtual, FixedUpdate};
45
43
/// means it is affected by [`pause()`](Time::pause),
46
44
/// [`set_relative_speed()`](Time::set_relative_speed) and
47
45
/// [`set_max_delta()`](Time::set_max_delta) from virtual time. If the virtual
48
- /// clock is paused, the [`FixedUpdate`](bevy_app::FixedUpdate) schedule will
49
- /// not run. It is guaranteed that the [`elapsed()`](Time::elapsed) time in
50
- /// `Time<Fixed>` is always between the previous `elapsed()` and the current
51
- /// `elapsed()` value in ` Time<Virtual>`, so the values are compatible.
46
+ /// clock is paused, the [`FixedUpdate`] schedule will not run. It is guaranteed
47
+ /// that the [`elapsed()`](Time::elapsed) time in `Time<Fixed>` is always
48
+ /// between the previous `elapsed()` and the current `elapsed()` value in
49
+ /// `Time<Virtual>`, so the values are compatible.
52
50
///
53
51
/// Changing the timestep size while the game is running should not normally be
54
52
/// done, as having a regular interval is the point of this schedule, but it may
55
53
/// be necessary for effects like "bullet-time" if the normal granularity of the
56
54
/// fixed timestep is too big for the slowed down time. In this case,
57
55
/// [`set_timestep()`](Time::set_timestep) and be called to set a new value. The
58
- /// new value will be used immediately for the next run of the
59
- /// [`FixedUpdate`](bevy_app::FixedUpdate) schedule, meaning that it will affect
60
- /// the [`delta()`](Time::delta) value for the very next
61
- /// [`FixedUpdate`](bevy_app::FixedUpdate), even if it is still during the same
62
- /// frame. Any [`overstep()`](Time::overstep) present in the accumulator will be
56
+ /// new value will be used immediately for the next run of the [`FixedUpdate`]
57
+ /// schedule, meaning that it will affect the [`delta()`](Time::delta) value for
58
+ /// the very next [`FixedUpdate`], even if it is still during the same frame.
59
+ /// Any [`overstep()`](Time::overstep) present in the accumulator will be
63
60
/// processed according to the new [`timestep()`](Time::timestep) value.
64
61
#[ derive( Debug , Copy , Clone , Reflect ) ]
65
62
pub struct Fixed {
@@ -71,8 +68,7 @@ impl Time<Fixed> {
71
68
/// Corresponds to 64 Hz.
72
69
const DEFAULT_TIMESTEP : Duration = Duration :: from_micros ( 15625 ) ;
73
70
74
- /// Return new fixed time clock with given timestep as
75
- /// [`Duration`](std::time::Duration)
71
+ /// Return new fixed time clock with given timestep as [`Duration`]
76
72
///
77
73
/// # Panics
78
74
///
@@ -113,7 +109,7 @@ impl Time<Fixed> {
113
109
}
114
110
115
111
/// Sets the amount of virtual time that must pass before the fixed timestep
116
- /// schedule is run again, as [`Duration`](std::time::Duration) .
112
+ /// schedule is run again, as [`Duration`].
117
113
///
118
114
/// Takes effect immediately on the next run of the schedule, respecting
119
115
/// what is currently in [`Self::overstep`].
@@ -134,9 +130,8 @@ impl Time<Fixed> {
134
130
/// Sets the amount of virtual time that must pass before the fixed timestep
135
131
/// schedule is run again, as seconds.
136
132
///
137
- /// Timestep is stored as a [`Duration`](std::time::Duration), which has
138
- /// fixed nanosecond resolution and will be converted from the floating
139
- /// point number.
133
+ /// Timestep is stored as a [`Duration`], which has fixed nanosecond
134
+ /// resolution and will be converted from the floating point number.
140
135
///
141
136
/// Takes effect immediately on the next run of the schedule, respecting
142
137
/// what is currently in [`Self::overstep`].
@@ -157,8 +152,8 @@ impl Time<Fixed> {
157
152
/// Sets the amount of virtual time that must pass before the fixed timestep
158
153
/// schedule is run again, as frequency.
159
154
///
160
- /// The timestep value is set to `1 / hz`, converted to a
161
- /// [`Duration`](std::time::Duration) which has fixed nanosecond resolution.
155
+ /// The timestep value is set to `1 / hz`, converted to a [`Duration`] which
156
+ /// has fixed nanosecond resolution.
162
157
///
163
158
/// Takes effect immediately on the next run of the schedule, respecting
164
159
/// what is currently in [`Self::overstep`].
@@ -174,7 +169,7 @@ impl Time<Fixed> {
174
169
}
175
170
176
171
/// Returns the amount of overstep time accumulated toward new steps, as
177
- /// [`Duration`](std::time::Duration) .
172
+ /// [`Duration`].
178
173
#[ inline]
179
174
pub fn overstep ( & self ) -> Duration {
180
175
self . context ( ) . overstep
@@ -221,8 +216,8 @@ impl Default for Fixed {
221
216
}
222
217
}
223
218
224
- /// Runs [`FixedUpdate`](bevy_app::FixedUpdate) zero or more times based on
225
- /// delta of [`Time<Virtual>`](Virtual) and [`Time::overstep`]
219
+ /// Runs [`FixedUpdate`] zero or more times based on delta of
220
+ /// [`Time<Virtual>`](Virtual) and [`Time::overstep`]
226
221
pub fn run_fixed_update_schedule ( world : & mut World ) {
227
222
let delta = world. resource :: < Time < Virtual > > ( ) . delta ( ) ;
228
223
world. resource_mut :: < Time < Fixed > > ( ) . accumulate ( delta) ;
0 commit comments