Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a Fixed Timestep #327

Open
rj00a opened this issue Apr 28, 2023 · 0 comments
Open

Use a Fixed Timestep #327

rj00a opened this issue Apr 28, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@rj00a
Copy link
Member

rj00a commented Apr 28, 2023

Describe the problem related to your feature request.

Valence currently uses the ScheduleRunnerPlugin to run each tick with a fixed delay. Problems arise because ScheduleRunnerPlugin does not account for thread::sleep inaccuracies. This is especially apparent on platforms like Windows where the timer resolution is very imprecise (16ms) by default. Regardless, this is probably not the intended use for ScheduleRunnerPlugin.

The obvious solution is to use bevy_time and CoreSet::FixedUpdate. However, there are two problems:

  1. The default base set for the Main schedule is CoreSet::Update. It's far too easy to accidentally add systems to the wrong set when .in_base_set(CoreSet::FixedUpdate) is forgotten.
  2. There are no standard PreFixedUpdate, PostFixedUpdate, sets. Plugins and Valence internally need to run code before and after user code.

Bevy 0.11 will fix (1) with the "schedule-first" redesign. But there is still no solution for (2).

What solution would you like?

When Bevy 0.11 is released, create a TickLoop schedule and use the facilities in bevy_time to run our own TickFirst, PreTick, Tick, PostTick, TickLast schedules in that order. User code goes in Tick.

What alternative(s) have you considered?

We could modify the app's runner to match the behavior of CoreSet::FixedUpdate. But that will cause problems for graphical plugins that will likely replace the runner by using WinitPlugin.

Additional context

@rj00a rj00a added the enhancement New feature or request label Apr 28, 2023
@rj00a rj00a linked a pull request Feb 11, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant