Using WorldToScreenPoint to account for a perspective camera, angle and position?

Hi , I’m having issues with aligning a cross hair to a vector3 which is a target lead position using WorldToScreenPoint however my player camera is in perspective and the position and angle seems to offset the alignment like in the image below.

I currently use my player transform to lookAt the target lead vector3 and use it’s forward direction * distance to set the crosshair in the top example on the screenshot but I use the vector3 of the target lead position in the second.

Is there a way I can account for the camera position,angle to make it more accurate so I can use my player transform forward direction as a crosshair?

Thanks

It should consider camera rotation and FoW by default.

Do you have only one camera, or several? Maybe you use WorldToScreenPoint for a wrong camera? For example if you use it as Camera.main.WorldToScreenPoint, maybe your camera does not have “MainCamera” tag.

Or maybe it happens due too large distance between clipping planes. 0.1 - 50000 it is too much. It may start to cause rendering problems due precision of floating point. Try to decrease far clipping plane to 5000 or 1000 for testing.

Hi @Artaani I currently just have the one camera and have tried reducing the distance of the clipping planes but the problem reoccurs only when I’m modifying the camera position.

I’ve also tried un-parenting the camera but the issue still occurs unless I set the camera position to vector3.zero

Edit

I found that my prediction lead pos from the crosshair gui and noticed it’s slightly out of sync which is causing the angle created when modifying the camera position.