Skip to content

time.delta() not compatible with .run_if() and timer conditions #8800

@ngreve

Description

@ngreve

Bevy version

0.10.1

What you did

use bevy::{
    prelude::*,
    utils::Duration,
    time::{common_conditions::*},
};
use text_colorizer::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_system(system_foo.run_if(on_timer(Duration::from_secs_f32(2.5))))
        .run();    
}

fn system_foo(time: Res<Time>) {
    println!("{}: Seconds since last update: {}","foo".blue() , time.delta().as_secs_f64());
    println!("FPS: {}", 1.0 / time.delta().as_secs_f64());
}

What went wrong

Maybe this is expected behavior, but in the given example
time.delta() shows the wrong delta, but visually the console output appears correctly every ~2.5 seconds.
I would expect time.delta() to be close to the configured 2.5 seconds, too.

In my case the console outputs:

foo: Seconds since last update: 0.00117275
FPS: 852.6966531656363
foo: Seconds since last update: 0.001393651
FPS: 717.5397570840906

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-TimeInvolves time keeping and reportingC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions