Hi there, seems like there were significant changes in how picker works from 1.68.0+
Previous:
var selected = picker.getSelection({
x: Math.floor(event.x * (picker.width / canvasWidth)),
y: picker.height - Math.floor(event.y * (picker.height / canvasHeight))
});
Current:
var selected = picker.getSelection(
Math.floor(event.x * (picker.width / canvasWidth)),
picker.height - Math.floor(event.y * (picker.height / canvasHeight))
);
And I’m seeing a huge differences in picking accuracy, any ideas how to get identical functionality as with previous picker version? Using old syntax causes an error
ASSERT FAILED:
Picker.getSelection:param 'rect' is deprecated, use 'x, y, width, height' instead.
The only change I see was to remove the support for the deprecated parameter, which was deprecated for a couple of years. Nothing else seems to have changed there.
Somebody else mentioned something similar:
Dear PlayCanvas Team,
After updating to PlayCanvas version 1.68.0, the picker framebuffer no longer consistently selects the correct entity when I click on it. This issue seems to occur after I move the camera or change the screen size. For example, when I attempt to select a capsule entity, the picker sometimes incorrectly identifies and selects a brick entity instead, even though the capsule was clearly clicked. This behavior is inconsistent, and the selected entity varies without apparent re…
Seems like I have the same identical issue
Same here.
The issue seems to be that y is no longer inverted (or is already inverted for us or something).
Anyway, my fix is
var selected = picker.getSelection(
Math.floor(event.x * (picker.width / canvasWidth)),
Math.floor(event.y * (picker.height / canvasHeight))
);
Tutorial: Entity Picking (PlayCanvas 3D HTML5 Game Engine ) actually has bug which is hidden because the scene is symmetrical.
1 Like