- Home /
Question by
Note0x16 · Oct 01, 2018 at 05:52 AM ·
cameracamera-movementcamera-look
Panning the Camera Based on a Fixed Point
So what I am trying to accomplish is moving the camera's x and y around based on the point where the mouse first clicked. So whenever the mouse is moved, the camera moves so that point remains under the mouse.
This is a 2d perspective so the z position of the camera does not matter.
How would I go about accomplishing this?
Thanks!
Comment
Answer by cnczcraft · Oct 01, 2018 at 06:45 AM
When the mouse is held convert the screen position to a world position and subtract it from the previous world position of the mouse (this can be done by logging the mouse position again at the end of the function and putting it in a vector). Take the inverse of the result and add it to the camera transform.