Closed tpuric closed 11 months ago
@tpuric Why did you close this? This does seem like something that should be resolved or at least an official response on how to handle it. I was also impacted by this.
Yeah, I'm also facing this issue too, I think this should be re-opened. Should I make a new issue?
Related https://github.com/aevyrie/bevy_mod_picking/issues/244#issuecomment-1689539413
Seems like this is known and perhaps expected.
Easy enough workaround though with a single camera.
fn update_handle_drag(
mut events: EventReader<Pointer<Drag>>,
mut query: Query<&mut Transform>,
query_projection: Query<&OrthographicProjection>,
) {
let projection = query_projection.single();
for event in events.read() {
let mut transform = query.get_mut(event.target).unwrap();
let scaled_delta = event.delta * projection.scale;
transform.translation.x += scaled_delta.x;
transform.translation.y -= scaled_delta.y;
}
}
The delta from a drag is intended to pass through the input values, with no modification. The example in repo simply doesn't handle any of this logic.
Related #244 (comment)
Seems like this is known and perhaps expected.
Easy enough workaround though with a single camera.
fn update_handle_drag( mut events: EventReader<Pointer<Drag>>, mut query: Query<&mut Transform>, query_projection: Query<&OrthographicProjection>, ) { let projection = query_projection.single(); for event in events.read() { let mut transform = query.get_mut(event.target).unwrap(); let scaled_delta = event.delta * projection.scale; transform.translation.x += scaled_delta.x; transform.translation.y -= scaled_delta.y; } }
Nice! Thank you! It works!
Drag delta not supported with camera
scaling_mode
.When adding
scaling_mode
to the camera, the delta is off by the scale factor as shown in the demo below. Interaction features (hover, select, deselect) all work as expectedhttps://github.com/aevyrie/bevy_mod_picking/assets/137123546/8600afa3-f3f3-4e81-9eb4-5fd75e0e0355
You can replicate this behaviour by switching the camera in the
drag_and_drop
example with what's shown below.Current workaround is to adjust the delta by the scale factor or utilise another mechanism. I am new to the library, so there may be some other configuration to adjust that I haven't come across. Love the library, very nicely done :)