Description
Bevy version
0.8.1
What you did
Create a system that responds to input events inside of a fixed times step.
What went wrong
Sometimes, input events are missed: Input::just_pressed
and just_released
are never picked up.
Other times, they're duplicated: we respond to the same input multiple times.
Explanation
Missed inputs
Fixed time step systems may not run every frame, but Input::just_pressed
and friends is reset every frame (and events are only double buffered). If the frame rate is significantly faster than the time step, the fixed time step schedule will sometimes not run, completely missing the input (which will no longer be just-pressed).
Duplicated inputs
If the fixed timestep is faster than the frame rate, fixed time step systems sometimes need to run catch-up, and are evaluated multiple times in the same frame. However, this will cause just_pressed
(or just_released
) to be registered as true multiple times (as Input
will not update between these system evaluations.
This can cause extremely confusing behavior. Note that, unlike missed inputs, events should not be affected by this failure mode, due to the internal cursor stored in EventReader
.
Proposed fix
We should have a default fixed time step system set (see the stageless RFC). Input updating (and input event clearing) should occur in there, rather than as part of the main schedule.
Gameplay systems should effectively always be run in the fixed time step: only rendering-related code should be processed each frame.
Ping @maniwani for thoughts.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status