-
I'm currently trying to learn how to use Base Sets, in particular StartupSet. On the documentation for bevy 0.10.1 it states that it runs once at the beginning of my app but when I use it in my code as shown below:
Despite using StartupSet::Startup with the documentation stating that it "Runs once when an App starts up", it repeatedly creates new entities and prints to the console "Order Check". Thankfully the order remains consistent with the output being:
However I'm trying to understand if this system is repeatedly called because I did something wrong in using "StartupSet::Startup". Just to clarify this isn't a question of how to ensure that something only runs once at startup as ".add_startup_system()" works perfectly for that purpose, this is more to trying to understand Base Sets along with how to use them to schedule properly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
base sets are a bit of a odd one. The concept will be completely revamped in 0.11. But to answer your question, let's take a look at the implementation of pub fn add_startup_system<M>(&mut self, system: impl IntoSystemConfig<M>) -> &mut Self {
self.add_system(system.in_schedule(CoreSchedule::Startup))
} It seems that it uses If you use Why can you add First let's do the dictionary game and define our concepts, so we are on the same page:
Sets and base sets by themselves are useless. In fact, they don't even exist! We just labelled systems with names. It's only thanks to Think of a jar. Your systems are balls. You can paint a ball yellow, green or blue before putting it in the jar. You now have three groups of balls in your jar: all the yellow balls, all the green balls and all the blue balls. Yet, you never added a "group" of balls in the jar.
A schedule has no way to tell whether a set "should" be part of it, it can only see which sets its system are said to be part of. You can put pink balls in your jar labelled "only yellow, green or blue balls" if you will. On a more practical notes, what's the point of sets? Remember that you can order systems with regard to each other: app.add_system(sys1.after(sys2)).add_system(sys2) It happens you can also order system sets. This means that an entire group of systems will be ordered with regard to another entire group of systems, much better than individually tagging and explicitly saying "a1 after b1", "a1 after b2", "a2 after b1"…
|
Beta Was this translation helpful? Give feedback.
base sets are a bit of a odd one. The concept will be completely revamped in 0.11.
But to answer your question, let's take a look at the implementation of
add_startup_system
It seems that it uses
.in_schedule
instead of.in_base_set
. So, in bevy 0.10, the startup schedule is completely distinct from the default schedule.If you use
add_system(sys1)
, you addsys1
to the main schedule, the one that runs every frame. Even if you label it with the.in_base_set(StartupSet::Startup)
. Thereforesys1
runs every frame.Why can you add
s…