# Why does my camera break mouse position targeting? [duplicate]

I made a short video of this.

Basically, when the screen scrolls with the camera, the character begins firing at the incorrect mouse position. You can see where I am clicking the whole time. As we move towards the right edge (the more we scroll), you'll notice the distance away from the correct position increases. The shooting mechanic worked just fine before I added the camera.

I'm using a translation matrix to implement my camera.

What could be causing this?

• This looks like the same problem as Mouse location is off due to camera. Is Jesse's answer there helpful? – Anko Feb 14 '14 at 11:06
• It works perfectly! To calculate the distance in X the mouse was away from the player, I was using distance.X = mouse.X - player.Position.X. I needed to convert mouse.X (screen position) to world coordinates, so added the position of the camera to that and voila! distance.X = camera.GetWorldPosition(mouse.X) - player.Position.X You have been tremendously helpful. Thank you so much. – atkayla Feb 14 '14 at 12:44
• Happy I could help. :) – Anko Feb 14 '14 at 13:27

Say you more all objects using xOffset by 500px, you then subtract xOffset from all objects so that they appear to be in the correct place. if you wanted the mouse to interact with them, you'd have to add the xOffset back onto the Mouses x coordinate.