# Screen Coordinates of an object's corners

 0 I'm wondering how to tell where the furthest left and "top" screen coordinates of an object is. I had thought to use the transform.collider.min and doing worldtoscreenpoint, but as the camera rotates around the object (especially around the x axis) this doesn't always hold up. Thanks! more ▼ asked Jun 20 '10 at 05:08 AM Adamv 3 ● 1 ● 1 ● 4 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 I'm afraid there's no easy solution for this. You could go over all the points of your collider, calculate screencoords and calculate min/max values on them. more ▼ answered Jun 20 '10 at 07:18 AM Jaap Kreijkamp 6.4k ● 20 ● 26 ● 70 Yeah, that sounds painful. If it can't be done, it can't be done though. Maybe I'll add a comment about this in the GUI thread at http://feedback.unity3d.com. Jun 20 '10 at 04:55 PM Adamv add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 If you still havent found an easier solution for this, here is my complicated and not very accurate solution. This is the function you need for getting an objects PIXEL SIZE (size drawn on screen) `````` //Gives pixel size of an object public static float angularSize (float diam, float dist, Camera cam) { float aSize = (diam / dist) * Mathf.Rad2Deg; float pSize = ((aSize * Scr.height) / cam.fieldOfView); return pSize; } `````` Where diam is, diam = transform.collider.bounds.extents.magnitude; dist is, dist = Vector3.Distance (transform.position, Camera.main.transform.position); cam is the camera you are using. This works for square or circular objects best. Then you can work your way through objects screen position and the objects screen size to find your answer. Regards, Aubergine more ▼ answered Sep 27 '10 at 02:39 PM add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x2987
x480
x151

asked: Jun 20 '10 at 05:08 AM

Seen: 2002 times

Last Updated: Jun 20 '10 at 05:08 AM