x


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?

more ▼

asked Oct 22 '11 at 06:17 AM

rsud gravatar image

rsud
100 16 21 24

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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).

more ▼

answered Oct 22 '11 at 06:34 AM

syclamoth gravatar image

syclamoth
15k 7 15 80

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x503
x470
x186
x156

asked: Oct 22 '11 at 06:17 AM

Seen: 4613 times

Last Updated: Oct 22 '11 at 06:34 AM