I’m having trouble implementing pixel-perfect panning for an orthographic camera in a 2D game (no character). Basically, I need Google Maps style controls.
Also, I change the OrthoWidth for zoom using the mouse scroll wheel, so I need to account for that.
I discovered that an OrthoWidth of 1080(camera settings) perfectly matches the mouse position with the scene while panning. So I get the current OrthoWidth and divide it by 1080(base value for perfect match) to scale the mouse movement. It works perfectly when the window width is ≥ 1080 in standalone mode. However, when I reduce the window width to something smaller than 1080, the panning starts to desynchronize. I suspect this might be related to my hardcoded OrthoWidth division or the DPI Scale curve (because 1080 is 1 there). I don’t want to disable DPI scaling ofc, and even if I do, it breaks again. What am I missing?
I tried that formula, but it didn’t match the mouse position with the point where panning started in the scene, but if you divide the height(Y instead of X), it works!
I figured that GetMousePositionOnViewport applies unnecessary DPI scaling, and the PlayerController→GetMousePosition is a few frames behind the actual mouse position or something, causing latency. But GetMousePositionOnPlatform is perfect for me, it’s absolute XY on the screen.
Thank you for answering, I didn’t expect anyone to respond at this point.