Hello,
I have a question about Camera.WorldToScreenPoint.
I actually want to draw a “target box” around the enemy. The canvas with the box image is a prefab, and the enemy has a script that instantiates the canvas as child of the enemy itself (not the best way but I’ll keept it this way for the moment).
Now the 1st problem is: since I use WorldToScreenPoint to translate the 3D position of the enemy into the 2D position on screen, the Z coordinate is missing and I see 2 target boxes, one around the enemy and the other one on the opposite side of my view. How can I avoid that? Should I deactivate/hide the canvas when the enemy renderer isn’t visible? Or is the a better way to do that?
2nd problem: at a certain distance, the target box disappears even if the enemy is still visible. I’m definitely below the far clipping plane… so, why is it happening?
Thank you in advance.
![]()