Repeat systems #8614
-
I want to repeat a system based on a count variable. How would I achieve that? A non-compiling snippet outlining my problem: use bevy::prelude::*;
fn main() {
App::new()
// Does not work, add_systems only accepts tuples:
.add_systems(std::iter::repeat(my_system).take(5))
.run();
}
fn my_system() {
println!("Hello world");
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This depends on multiple factors:
For example, if you want to repeat the system's functionality within a frame, have the number of repetitions be variable and modified by other systems in your app, I would do the following:
(I didn't check if the example code actually compiles so you might need to adjust it a bit) |
Beta Was this translation helpful? Give feedback.
This depends on multiple factors:
For example, if you want to repeat the system's functionality within a frame, have the number of repetitions be variable and modified by other systems in your app, I would do the following:
Introduce a
Resource
struct wrappingusize
to define the repetition count:Initialize the resource to the count you want to start with.
Mod…