Hey guys, I’m making a game in which I need to convert screen coordinates to world coordinates. The player has the ability to move/zoom the camera, and I want a click/tap to properly correspond with the world.
I know the traditional way of doing this is:
Vector2 clickPos = new Vector2(x, camera.viewportHeight - y);
camera.unproject(new Vector3(clickPos, 0));
However, this doesn’t seem to work for me. I’m not sure how to describe the problem, but it just isn’t giving the right world coordinates.
Everything in my world is drawn at a scale of 2, so I thought that meant I had to scale the vector but that gave this weird exponential effect.
I know I’m doing something wrong, but everywhere I look it only goes into the amount of detail above. Let me know if you need some screenshots of the situation
if there doesn’t seem to be anything obviously wrong.
Thanks guys!