- Home /
Question by
rsud · Oct 22, 2011 at 06:17 AM ·
3dscreencoordinatesspace
getting screen coordinates for 3d object?
I have an 3d object in 3d space displaying on the Touch screen (Unity iPhone) that is in front of the camera.
In a script tied to this object how can I determine what the 2d screen coordinates are for this object on the Touch screen?
Comment
Best Answer
Answer by syclamoth · Oct 22, 2011 at 06:34 AM
There is this lovely function, WorldToScreenPoint in the Camera API. Use it like this-
2dCoordinates = Camera.main.WorldToScreenPoint(worldPosition);
There is also one which gives you the coordinates in normalised screen space- if that's what you need instead: WorldToViewportPoint(Vector3).
Your answer
![](https://koobas.hobune.stream/wayback/20220613015904im_/https://answers.unity.com/themes/thub/images/avi.jpg)