bevyengine / bevyengine/bevy

Remove `StateTransition` schedule in favor of using observers

Open
#15,133 11 comments 1 reaction 0 assignees View on GitHub
A-States C-Feature D-Modest M-Migration-Guide S-Ready-For-Implementation X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Updating the app state is a very flexible and expressive operation, which is fundamentally deferred. States typically changes only once per frame, after `PostUpdate`.

This can lead to unwanted delays when handling multiple dependent transitions at once.

## What solution would you like?

As discussed in #15127, it would be nice to remove this meta-schedule, and instead run the various `OnEnter` / `OnExit` / `OnTransition` schedules on demand, leveraging the new observers. This is a good fit for "highly complex rarely exercised logic", and resolves the delay problem mentioned above while simplifying the mental model for consumers.

#15127 should be tackled in concert with this, removing `NextState` completely, and relying entirely on commands to handle transitions.

## What alternative(s) have you considered?

Users can manually add more state transition systems to their schedule, including in their own schedules that run inside of `Main`. This is somewhat messy, nonstandard and hard to discover.

## Additional context

Discussed briefly on Discord with @MiniaczQ [here](https://discordapp.com/channels/691052431525675048/749335865876021248/1282862231570092033).

This design was not originally taken (including in the substates refactor) because observers didn't exist at the time!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.