bevy_pancam
bevy_pancam copied to clipboard
Fix incorrect drag when pressing after a movement
implements suggestion from https://github.com/johanhelsing/bevy_pancam/pull/48/files#r1346483971
Description from https://github.com/johanhelsing/bevy_pancam/pull/48:
When combining pancam drag with other draggable elements, I wanted to disable pancams before it could move.
Unfortunately the current pancam movement implementation can move the camera the first frame we detect a button_grab, as if user was already button_grabing previous frame.
more context for this: https://discord.com/channels/844211600009199626/1158800311171960972/1159149631117201419
Most important information from discord's discussion:
pancam's implementation leads to such scenario:### frames
- no click, position(0,0)
- click, position(0,1) -> pancam detects a drag (because we cached last position, without checking for grab_button) and moves (green 🟢) ; but bevy_mod_input only detects the click (I think that's more correct)
- position(0,2) -> I disable the pancam (red 🔴), pancam doesn't run (orange 🟠 )