[SOLVED] How to set correctly the crosshair on the screen?

Hi, everybody!

I am developing a third person shooter. I have a player with a weapon. The weapon at the end of the barrel has a point, that makes ray casting forward at a given length. Also in the project there is a 2D screen on which a picture of the crosshair is installed. I tried to set the crosshair on the screen using the .worldToScreen() method, but I did not succeed. Crosshair is installed in the wrong place. Tell me, please, how to correctly make the installation of a crosshair on the screen, based on the device screen size and coordinates of the end of the ray, which ray cast provides?

I managed to set the crosshair on the screen, but I had another question. I set the crosshair on the screen based on the coordinates of the entity point for which ray cast was successfully executed. But what length a ray should be used when ray cast not performed? Should I be guided by the size of the game world?

As short as possible. The longer it is, the, more expensive it becomes to run as it potential more physics objects to sort through and test against.

1 Like

Thanks for the reply. :slightly_smiling_face: