Add an additional constructor method to `ManualEventReader`, which starts at the current frame's events
- 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?
#5730 introduced a generally helpful error message,
> 2022-11-13T19:35:54.363800Z WARN bevy_ecs::event: Missed 345 `bevy_input::mouse::MouseMotion` events. Consider reading from the `EventReader` more often (generally the best solution) or calling Events::update() less frequently (normally this is called once per frame). This problem is most likely due to run criteria/fixed timesteps or consuming events conditionally. See the Events documentation for more information.
However, when working with `ManualEventReader` to read recent events via [`Events:;get_reader`](https://docs.rs/bevy/latest/bevy/ecs/event/struct.Events.html#method.get_reader), this error is triggered constantly.
## What solution would you like?
The correct solution here, is to instead initialize the manual event reader at the start of the events that occured this frame. This avoids double-reading, and silences the warning.
In order to do this however, `bevy_ecs` needs to expose a constructor ala `get_current` that sets the internal `events_seen` field correctly.
## What alternative(s) have you considered?
We could instead (or additionally) allow public construction of `EventReader` from `Events`, but this feels more likely to be confused and misused.
Adding public access to `ManualEventReader` of `EventReader` may work to solve my particular issue as well, albeit in a bit messier of a way.
Contributor guide
Assessment
This issue has not been assessed yet.