-
I'm just trying to come to understand how to interact with the scheduling systems in bevy. I've written a simple script in bevy 0.10.1 which first uses the Commands struct to queue to spawn an entity with a num(u32) component. I then chain together "apply_system_buffers" followed by a Query for that num component for which I deliberately use .get_single().unwrap().0 to cause an error if the entity didn't spawn before the function call. The full code is below:
If I use ".add_startup_system(command_spawn)" it prints out the expected value 12 repeatedly but using .chain() with apply_system_buffers buffer or using
in place of In summary I'm just trying to figure out what I did wrong and how can I organize the scheduling of systems to follow my intentions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Ah I know what I did wrong. Obviously don't add a system to an app which repeatedly spawns something while also trying get a single, additionally don't code at 3 in the morning. When implementing everything properly everything works as expected For the full proper implementation use: |
Beta Was this translation helpful? Give feedback.
Ah I know what I did wrong. Obviously don't add a system to an app which repeatedly spawns something while also trying get a single, additionally don't code at 3 in the morning.
When implementing everything properly everything works as expected
For the full proper implementation use:
.add_startup_systems((command_spawn,apply_system_buffers,query).chain())
This will work as expected and print out the value 12 once. Additionally removing apply_system_buffers while still keeping them in a chain can sometimes still allow it to function (but obviously don't rely on this) while removing the chain guarantees that an error will be thrown.