- Home /
UI image showing up "behind" player.
Hello All,
Ok I have tried searching what my issue might be, and I know I have got this working before but I seem to be stuck.
I have a simple lock on system that makes a lock on target appear above an enemy when the user completes lock on. The reticle successfully follows the enemy around the screen when I move it. The canvas is set to screen-space-overlay.
It works OK, however when rotating the camera, the image shows up "behind" the player. I know its not technically behind the player but you know what I mean. I know I have figured this out before but my brain appears to be stuck. What am I missing here?
I have tried a World Space Canvas but I figured this is more in line with setting it up in the 3d World, not just have a 2D image on the screen.
The main code used is the following:
Vector3 lockonPos = Camera.main.WorldToScreenPoint(this.transform.position);
crossHair.transform.position = lockonPos;
Can someone possibly point me in the right direction? Thank you!
Answer by millej23 · May 12, 2020 at 01:16 PM
I was able to get around using cameras and canvases using a Plane and creating a material using the triangle and having it look at the player upon creation. Seems to be much easier.
Answer by fblast1 · May 07, 2020 at 01:29 AM
If it is a world space canvas probably the canvas is children to the camera and when you rotate it will keep showing.
Regards
Your answer
![](https://koobas.hobune.stream/wayback/20220612233514im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
problem with canvas 0 Answers
How to attach a (that world type) canvas to a moving player? 0 Answers
UI text vs. moving camera 1 Answer