Function bevy::prelude::apply_state_transition

pub fn apply_state_transition<S>(
    event: EventWriter<'_, StateTransitionEvent<S>>,
    commands: Commands<'_, '_>,
    current_state: Option<ResMut<'_, State<S>>>,
    next_state: Option<ResMut<'_, NextState<S>>>
)
Expand description

If a new state is queued in NextState<S>, this system:

If the State<S> resource does not exist, it does nothing. Removing or adding states should be done at App creation or at your own risk.

For SubStates - it only applies the state if the SubState currently exists. Otherwise, it is wiped. When a SubState is re-created, it will use the result of it’s should_exist method.