Objects in 3D space converted to 2D screen position?

Hello,
I have a crosshair that is set up to move based on mouse movement. In 3D space., I would like to limit the crosshair to not go off my screen. Based on where the crosshair is from my camera’s view, is there a way to return Vector2(0, 0) if my crosshair is in direct view of the camera, and Vector2(-1, 0) if my crosshair is 1 pixel away from going off the left side of my screen, and Vector2(0, 1)) if it is 1 pixel away from going off the bottom of my screen, based on where the crosshair is in 3D space? I would also like the window screen size to be s factor too. Thank you.

Check the manual, there are transformation methods for coordinate system-changes:

Thank you. I don’t understand exactly how WorldToScreenPoint() works (in algorithm), Whenever my object is in direct view of my camera, I was expecting to get something like…

Vector2(0, 0), Vector2(0.5, 0.5), Vector2(Screen.width/2, Screen height/2), or a value that is constant,

I used…

Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
Ray ray = Camera.main.ScreenPointToRay (new Vector2(pos.x / Screen.width, pos.y / Screen.height));

and got around 3 different Vector2 values even though the object is centered in my camera’s view.

[SOLVED]

I was able to figure out how WorldToScreenPoint() works. I don’t have to divide by width and height of my screen, and was able to fix the problem. It turned out that my crossheir script somehow ended up on 3 other objects.