Hi everybody
I’m currently placing a 2D plane with a custom shader (circular progress bar) in front of my camera. However, I would like to place it at a 2D screen position. I tried converting screen pixel positions to 3D space but I can’t get it to work.
Any help would be appreciated
Check out Camera.ScreenToWorldPoint() - feed it a Vector3 with the desired screen position as x/y and the desired distance to the Camera as the z.
So something like this should work: transform.position = Camera.main.ScreenToWorldPoint(new Vector3(50f, 50f, 300f));
Optionally you might want to add a transform.LookAt(Camera.main.transform);
so your circle faces the camera (if it’s front is on the z axis, as it should be)
I’ve already tried this.
And for the life of me I can’t get the %&#/! lookat script to work. The plane is just not visible.
Debugging tells me that it’s not pointing the right way. I attached a lookat script to the plane in question (The prefab have 2 sub planes)
Also ScreenToWorldPoint does not place it in the correct place?!
Thanks for your help. Any other ideas? Is there some way I can get the plane to be drawn on top of all other geometry? (besides moving it)
Hi all. Thank you for your help.
I’ll have a look at it 