Scene.pick() breaks with Scene Optimizer hardware scaling

I noticed when the Scene Optimizer changes hardware scaling, my scene.pick(canvas.width/2, canvas.height/2) and scene.pickSprite() are off by maybe 10% from where they should be on the screen.

Maybe I should use a different value to pick from the center of the screen? Or maybe there is a bug when it’s scaled.

I’ve seen a couple posts similar but not quite the same issue. I can possibly make a PG later if nobody has any ideas.

Could you provide a PG? It would be easier for us to take a look.

1 Like

https://playground.babylonjs.com/#IXCQWT

It console logs when it is picking a mesh.

You need to multiply the coordinates by engine.getHardwareScalingLevel() before picking:

https://playground.babylonjs.com/#IXCQWT#2

2 Likes

That makes perfect sense! Thank you so much!