#How to run systems only in a specific state after Bevy 0.10?

1 messages · Page 1 of 1 (latest)

buoyant sorrel
#

Hi, I am using bevy 0.12.1 and I can't see how to run a system in a specific state since run_if() seems to not exists anymore. Following this bevy 0.10 tutorial we could use run_if() this way:

app.
  // Previous code
  .add_system(sample_system.run_if(in_state(SampleState::State)))

Trying to implement the same code in bevy 0.12 I get the following error: no method named run_if found for fn item fn(Commands<'a, 'b>, Res<'c, Input<KeyCode>>, ...) {toggle_simulation} in the current scope.

I tried to check the bevy cheat book and migration guides but could not found an example of this implementation. (Bevy cheatbook is outdated)

worthy ibex
#

You would probably use

app.add_systems(Update, (your_system_one, ystwo).run_if(in_state(Your_state)))
shadow python
#

This should work as before. Are you sure your system is valid?

buoyant sorrel
#

Sorry, it was an import error.

I was importing bevy create with use bevy::prelude::{App, Plugin, States, Update}; . After updating to use bevy::prelude::* it works.