-
So what I need now is just to chain systems like function calls. But I really can't decide which one to choose. Here's the list of what I have come up with. Ideally there just would be something like FunctionsI could make the sub-systems just regular functons, but this has several downsides:
EventsI could also make use of events. However I need the data got from the previous system to properly execute the next one. I could also make a ton of events and call them one-by-one from each system. This, however also is bad because these execute frame-by-frame (the next is executed the next frame) and result in noticable chains. And even then sometimes something just fails and the data still doesn't get written by the time system is executed. StagesI could combine events and stages to hopefully get better results. However this still doesn't fully apply to my use case. Imagine I register the system in the second-after-update stage, but somewhere in the code I realize one of the chains is longer, so I need to go and insert a new stage (which isn't a pleasant experience either). So what do you think? I currently sticked with the slow event system, but even there it seems i use events wrong. I might misunderstand something, in that case you can point it out. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Assuming you are aware of the
The transform system tests are a good example of this: bevy/crates/bevy_transform/src/systems.rs Lines 203 to 220 in 80db794 In this particular case, you still want the systems to be properly ordered, so the schedule.add_systems((sync_simple_transforms, propagate_transforms).chain()); |
Beta Was this translation helpful? Give feedback.
-
You can also use system piping to read the output of fn sys1(query: Query<&Foo>) -> Vec<Vec2> {
// ... return a `Vec<Vec2>`
}
fn sys2(positions: In<Vec<Vec2>>, mut query: Query<&mut Bar>) {
// use both `query` and `positions` to do things
}
// ...
app.add_systems(
Update,
sys1.pipe(sys2)
) |
Beta Was this translation helpful? Give feedback.
Assuming you are aware of the
(sys1, sys2, sys3).chain()
combinator as in theecs_guide.rs
example, and you are asking for a way to run systems outside of the regular scheduling system. You need exclusive world access for this.The transform system tests are a good example of this:
bevy/crates/bevy_transform/src/systems.rs
Lines 203 to 220 in 80db794