How to make a camera that moves by dragging your mouse?

Daanny

Member
I could only find one tutorial on youtube about this but even after copying the entire thing word for word the camera seems to snap to really weird positions before moving, and it only correctly moves if my mouse starts dragging from the very top left corner of the screen. Also for some reason the camera moves around faster than my mouse does, about 3 pixels for every 1 pixel my mouse moves.
Heres the tutorial, I did literally everything identical to this tutorial so there isnt much point in showing my code:
Is there some easy way of doing it or is it just more complex than I think?
 
the camera seems to snap to really weird positions before moving, and it only correctly moves if my mouse starts dragging from the very top left corner of the screen.
This is to do with the offset. Each time you reposition the camera while you're dragging it, you'll be adding a value to the x and y of the camera. Check that this is
1. being added in the first place and
2. isn't inverted (try putting - before each one).
 

Daanny

Member
This is to do with the offset. Each time you reposition the camera while you're dragging it, you'll be adding a value to the x and y of the camera. Check that this is 1. being added in the first place and 2. isn't inverted (try putting - before each one).
Well strangely, if I divide rawposX and rawposY by 4.3, it works fine. No idea why it works or why specifically 4.3 but I'm not complaining
 
Top