2580 Split examples PR feedback#15181
Conversation
examples/camera/camera_orbit.rs
Outdated
| } | ||
|
|
||
| #[derive(Debug, Default, Resource)] | ||
| struct MouseButtonsPressed { |
There was a problem hiding this comment.
Maybe the example would be a bit slimmer without this resource? I get that actions should be separated from keycodes, but we read them in the same system as we do the movement right now anyways.
There was a problem hiding this comment.
This could be me wildly misunderstanding the problem, but: I think only one event gets sent per button pressed (and one on button release). So, the problem becomes how to detect if the user is holding the button, hence the resource.
There was a problem hiding this comment.
That would be input.just_pressed. input.pressed is true when it was pressed in the first frame and stays true when held the next frames.
There was a problem hiding this comment.
Edit: Ah, I see your problem! You're using EventReader<MouseButtonInput>. Use Res<ButtonInput<MouseButton>> instead, that already handles this stuff for you :)
There was a problem hiding this comment.
Dammit lol I knew something weird was going on!
Objective
Applies feedback from previous PR #15135 'cause it got caught up in the merge train 🚂
I couldn't resist including roll, both for completeness and due to playing too many games that implemented it as a child.
cc: @janhohenheim