- Home /
Convert screenspace coordinates (top-left origin) to worldspace coordinates. Read before you react!
OK, I give up.
I'm trying to convert a screenspace coordinate to worldspace coordinate and I was able to perform some transformations using
Camera.ViewportToWorldPoint Camera.ScreenToWorldPoint
They transform, but incorrectly. Is there anything else I should consider before using these methods?
This guy seems to have the same problem too: http://answers.unity3d.com/questions/26040/converting-from-screen-to-world-space-it-seems-bro.html
Thanks in advance.
Answer by Bunny83 · May 18, 2012 at 09:25 AM
They work as they should. Where do you use the world position? The other question you've linked has a different problem i guess. He's using the GL class without setting a projection / modelview matrix so his coordinate system is something from the last rendered object.
Just read the docs on
GL.LoadOrtho sets up a ortographic projection so you can use directly viewport coordinates
GL.LoadProjectionMatrix sets the given matrix as projection matrix
GL.modelview sets the modelview matrix
Your answer
Follow this Question
Related Questions
Export camera path (first person controller) in x,y coordinates 2 Answers
Could anyone explain me this ThirdPerson camera Script? 1 Answer
help with my orbit camera script 0 Answers
How to get screen coordinates of object from shader 0 Answers
Applying velocity to non rigid body object? By math? 2 Answers