Jump to content

Covert screen coordinates to World's x and y


Recommended Posts


I've searched the forum, but most questions and answers that I found relate to the reverse: convert World to Screed coordinates. 
The reason I need this is to launch a projectile in the direction of mouse coordinates when a user clicks on a screen. I tried the ray picking approach, but 1) it's too cumbersome and it didn't work, and 2) there's nothing to pick with a ray! :)

I wonder if anyone here had the same issue and managed to find a solution.


Link to comment
Share on other sites

Well, you are clicking in a 2D space, what would you expect to get?  let's say your camera is parallel to the floor, pointer straight at the z axis. Let's say we have y (which is 0) and x (which is also 0). What would you expect Z to be?

Picking is your friend (which is rather straight-forward). You will need to add a picking mesh (a plane, for example) that will transform your single click to 3d coordinates according to your definition. This would be the simplest way.

Link to comment
Share on other sites

Why pseudo, when you can get the real thing:



wall is your collision wall, I set it's material's alpha to be 0.3 (so you will see where it is). the pick result is the position in the world that you clicked on. notice that the wall's parent is the camera, and that it is 20 units away from it, so this would be your z axis (local coordinates).


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...