The shot goes to the wrong place when the camera is zoomed or moved
Aiming works perfectly with a fixed camera and falls apart the moment the view scrolls, zooms or the window is resized: the mark and the click disagree by a growing distance. The conversion between screen and world needs three details that are easy to forget.
Why this works
The pointer lives on the screen and the target lives in the world, so every click needs a translation between the two. If the translation uses exactly what is drawn this frame, mark and click always agree, at any zoom or window size.
When not to use it
Not needed when aiming does not use a pointer at all, such as with a gamepad stick or a fixed lane, or when the camera never moves or zooms. Then the screen position already is the world position, and the extra step adds only chances for error.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 26 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "The shot goes to the wrong place when the camera is zoomed or moved" (read_entry mouse-aim-wrong-with-zoomed-camera) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP