1 unstable release

0.3.0 May 2, 2022
0.2.0 Feb 10, 2022
0.1.1 Feb 4, 2021
0.1.0 Jan 29, 2021

#1307 in Game dev

MIT/Apache

8KB
108 lines

Bevy-tick-timers

Provides a Bevy plugin for scheduling and managing tick based timers.

Tick based timers are timers that operate not on real time, but on the number of state updates that occur. Each state update constitutes a "tick".

For any timer that does not update outside a game session, a tick based timer is preferred. This makes games more consistent and replayable (which also means they are easier to debug).

Example:

use bevy::prelude::*;
use bevy_tick_timers::{TimerPlugin, Timers};

fn add_timer(
    mut timers: ResMut<Timers>,
) {
    // Timers are Bevy systems, and thus can be closures. 
    timers.after(5, (move || {
        println!("timer has gone off!");
    }).system());
}

fn main() {
    println!("starting up");
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(TimerPlugin)
        .add_startup_system(add_timer.system())
        .run();
}

lib.rs:

bevy-tick-timers provides a Bevy plugin that enables the use of tick based timers.

Tick based timers are timers that operate not on real time, but on the number of state updates that occur. Each state update constitutes a "tick".

For any timer that does not update outside of a game session, a tick based timer is preferred. This makes games more consistent and replayable (which also means they are easier to debug).

Example:

use bevy::prelude::*;
use bevy_tick_timers::{TimerPlugin, Timers};

fn add_timer(
    mut timers: ResMut<Timers>,
) {
    // Timers are closures that take the world as a mutable reference.
    timers.after(5, |_| {
        println!("timer has gone off!");
    });
}

fn main() {
    println!("starting up");
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(TimerPlugin)
        .add_startup_system(add_timer.system())
        .run();
}

Dependencies

~16–26MB
~475K SLoC