Skip to content

Commit 554bc7b

Browse files
authored
Document repeating timer tick behavior (#20137)
# Objective Closes #20132 ## Solution I found docs describing the behavior elsewhere in Bevy, which I pulled in to the main `Timer` docs: https://github.com/bevyengine/bevy/blob/b01de70bdd927bcc9cdc5d0b8c677f480e54f4b1/crates/bevy_time/src/common_conditions.rs#L27-L35 I also restructured the docs a little bit.
1 parent 2cb8450 commit 554bc7b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

crates/bevy_time/src/timer.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@ use core::time::Duration;
55

66
/// Tracks elapsed time. Enters the finished state once `duration` is reached.
77
///
8-
/// Non repeating timers will stop tracking and stay in the finished state until reset.
9-
/// Repeating timers will only be in the finished state on each tick `duration` is reached or
10-
/// exceeded, and can still be reset at any given point.
8+
/// Note that in order to advance the timer [`tick`](Timer::tick) **MUST** be called.
119
///
12-
/// Paused timers will not have elapsed time increased.
10+
/// # Timer modes
1311
///
14-
/// Note that in order to advance the timer [`tick`](Timer::tick) **MUST** be called.
12+
/// There are two timer modes ([`TimerMode`]):
13+
///
14+
/// - Non repeating timers will stop tracking and stay in the finished state until reset.
15+
/// - Repeating timers will only be in the finished state on each tick `duration` is reached or
16+
/// exceeded, and can still be reset at any given point.
17+
///
18+
/// # Pausing timers
19+
///
20+
/// You can pause a timer using [`Timer::pause`]. Paused timers will not have elapsed time increased.
21+
///
22+
/// # Elapsing multiple times a frame
23+
///
24+
/// Repeating timers might elapse multiple times per frame if the time is advanced by more than the timer duration.
25+
/// You can check how many times a timer elapsed each tick with [`Timer::times_finished_this_tick`].
26+
/// For non-repeating timers, this will always be 0 or 1.
1527
#[derive(Clone, Debug, Default, PartialEq, Eq)]
1628
#[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))]
1729
#[cfg_attr(

0 commit comments

Comments
 (0)