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

Add an additional constructor method to ManualEventReader, which starts at the current frame's events #6589

Open
alice-i-cecile opened this issue Nov 13, 2022 · 1 comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

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, 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.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Nov 13, 2022
@alice-i-cecile alice-i-cecile changed the title Add an additional constructor method to ManualEventReader, which starts at the current frame's events0 Add an additional constructor method to ManualEventReader, which starts at the current frame's events Nov 13, 2022
@alice-i-cecile alice-i-cecile modified the milestone: 0.9.1 Nov 13, 2022
@alice-i-cecile
Copy link
Member Author

Note that even if #6596 is merged, I think this is still worth doing: it's a sensible and helpful pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

1 participant