i have 2 systems: .add_systems(PostStartup, (calculate_world_bounds, spawn_boids.after(calculate_world_bounds))); in calculate_world_bounds im inserting world_bounds as a resource like so commands.insert_resource(WorldBounds { bottom_left: world_left_bottom, right_top: world_right_top, }); and then im trying to access the resources in spawn_boids spawn_boids(mut commands: Commands, world_bounds: Res<WorldBounds>). however this leads to the error Resource requested by rounds_in_rust::demos::boids_plugin::spawn_boids does not exist: rounds_in_rust::demos::boids_plugin::WorldBounds wich is quite confusing. can someone explain to me why this is happening and what im doning wrong / have missunderstood?
#Resorce doesnt exists after commands.insert_resource
9 messages · Page 1 of 1 (latest)
Commands aren't applied instantly
Instead they wait until the next apply_deferred or the end of the schedule
thx
can i force this somehow?
as the doc string for apply_defered sais````Instructs the executor to call System::apply_deferred on the systems that have run but not applied their Deferred system parameters (like Commands) or other system buffers.
Notes
This function (currently) does nothing if it's called manually or wrapped inside a PipeSystem.
Modifying a Schedule may change the order buffers are applied.````
One option is to put the two systems into separate schedules, ie calculate in Startup and spawn in PostStartup, this will naturally ensure the sync point is hit between them
If that won't work for you for some reason, you can add the apply_deferred manually and order your systems around it, such as (calculate, apply_deferred, spawn).chain()