Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to convert touch/click input (2D coordinates) to 3D coordinates by dropping the Z axis (would like to move only up/down, left/right (Z is the axis for depth).

The problem is that the coordinates i get from input (2d) aren't corelated with the 3d actual space.

Does XNA provide a way to do this?

share|improve this question
Just a guess, mouse ray can be the answer (: –  Gustavo Maciel Jan 19 '12 at 11:10
@Gtoknu thanks! i'll give it a try! i'll be back with feedback –  Badescu Alexandru Jan 19 '12 at 11:22

1 Answer 1

You want to have a look at this: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.unproject.aspx

share|improve this answer
this only shows if a touch input intersects an object. i actually need to generate the next position (while dragging) for the object. i solved it with some good ol' fashion vector geometry : math.stackexchange.com/questions/100439/… –  Badescu Alexandru Jan 21 '12 at 8:32
Using unproject from the near plane and far plane you get a line segment that spans the entire camera's view, you could then move your object along that line segment. However, as you've said, you've already solved the problem. –  Nic Foster Jan 23 '12 at 19:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.