Bevy 0.11 - How to have two systems running in different fixed time steps ? #9197
-
|
In the Bevy Examples here, it shows how to have systems running in the same fixed time step: use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(FixedUpdate, fixed_update)
.insert_resource(FixedTime::new_from_secs(0.5))
// ^ How to add system with another fixed time step ?
.run();
}But I cannot find the way to setup two systems running in different time steps. In bevy 0.9, it was possible using the use bevy::time::FixedTimestep;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_system_set(
SystemSet::new()
// This prints out "hello world" once every second
.with_run_criteria(FixedTimestep::step(1.0))
.with_system(slow_timestep)
)
.add_system_set(
SystemSet::new()
// This prints out "goodbye world" twice every second
.with_run_criteria(FixedTimestep::step(0.5))
.with_system(fast_timestep)
)
.run();
}
fn slow_timestep() {
println!("hello world");
}
fn fast_timestep() {
println!("goodbye world");
}What is the way to do that in bevy 0.11 ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Generally speaking, you really only want one fixed timestep: this should be used for synchronizing all of your logic for physics and networking stability. If you just want to run your system every x seconds use a If I'm wrong and you really, really want two copies of the looping logic, dig into the source code and cannabilize what we've done with the outer schedule: it should all be user reproducible. |
Beta Was this translation helpful? Give feedback.
Generally speaking, you really only want one fixed timestep: this should be used for synchronizing all of your logic for physics and networking stability.
If you just want to run your system every x seconds use a
on_timerrun condition instead.If I'm wrong and you really, really want two copies of the looping logic, dig into the source code and cannabilize what we've done with the outer schedule: it should all be user reproducible.