Posted 13 May 2012 - 05:03 PM
I've read about how to do this before, and the problem can be solved with ray casting. I have never actually implemented it, but I can give you a high-level idea of how i think it might work.
Somewhere in your code, you must be storing the camera's position and the direction it is looking. If the player were to click in the exact center of the screen, you could imagine a ray coming out of the camera's position, travelling in the direction the camera is looking. If the ray were long enough, you could compute which tile that ray intersected (if any).
Now let's say the player does not click in the exact center of the screen. Imagine a plane centered on the camera's position, perpendicular to the direction the camera is looking. Wherever the player clicked would correspond to some point on that plane. If there were a ray coming out of that point, in a direction parallel to the camera's direction, you could compute which tile that ray intersects (if any).
First, let me make sure I understand your question. You want to have the user click the mouse, and be able to tell which tile they clicked on. The problem is, you can only get the mouse coordinates in screen space, and your tile data is stored in world space. Is that right?