Converting world point to screen point

i am trying to make labels for my objects in the scene. obviously i dont know how to properly convert world to screen coords, they seem to rotate around 3d space but they shouldnt

here is the code i use:

    function OnPostRender() 
        var origin :;

        GL.Begin( GL.LINES ); 
        GL.Vertex3(cam.targetPosition.x ,cam.targetPosition.y, cam.targetPosition.z ); 
        GL.Vertex3( 1,0, 0 ); 

i know this code isnt good, it was just for testing. i want line to go from the middle of the object (that is targetPosition Vector3) and other point should be, let's say 1 point long left or right from the object position, it should just project to the screen, not in 3D space

EDIT: i tried this, but it didnt get me too far (i used origin variable):

function OnPostRender(){;




        GL.Vertex3(origin.x ,origin.y, 0);

        GL.Vertex3(origin.x+0.1 ,origin.y+0.1,0); 


i simply dont get this.. :( what i am trying to do is to do labels for my objects in the scene. first step would be to get the position of the object and draw the line from that point and point that is offset a little. that worked fine if i used for example

GL.Vertex3(cam.targetPosition.x ,cam.targetPosition.y, cam.targetPosition.z);
GL.Vertex3(cam.targetPosition.x+0.5 ,cam.targetPosition.y+0.5, cam.targetPosition.z); 

but it rotated in 3d space so my guess was that i need to project the offset point to viewport of screen space, but every combination i tried didnt is so frustrating...

if i use WorldToScreenPoint i get huge numbers for origin.ToString() so i am using WorldToViewportPoint... this seems to be so simple, but i cant get it to work

You declared the "origin" variable but you're not doing anything with it.

I’m not entirely sure of your problem but if it is what I think it is and you are using a static camera or you always want your labels to face the camera I added this to my text labels for items in a script:

function Update () {
transform.rotation = Camera.main.transform.rotation;

Now my text labels for items / players / anything always face the camera.
I am using a Text Mesh to create labels above my items.

Hope this helps, and apologies if I have misunderstood the issue.