#System with world-access and run_if

2 messages · Page 1 of 1 (latest)

wicked pelican
#

Using bevy 0.13.

s there any way to conditionally run a system that has world access?

E.g. given this system:

fn world_system_test (
    world: &mut World,
) {

}

Adding it like this

app.add_systems(Update, world_system_test).run_if(in_state(GameState::InGame))

.. gives me a long error starting like this:

error[E0599]: the method `run_if` exists for mutable reference `&mut App`, but its trait bounds were not satisfied
  --> src/lights.rs:16:53
   |
11 | /         app.add_systems(Update, world_system_test).run_if(in_state(GameState::InGame))

So is there a nice way to accomplish that, other than specifically checking for GameState::InGame inside the system?

weary schooner
#

You're trying to add the run_if to App instead of the system, it should look like rs app.add_systems(Update, world_system_test.run_if(in_state(GameState::InGame))