GUI behind Camera - WorldToScreenPoint

Hey there,

I’m having a rather pesky problem and I just can’t figure out how to fix it: I’m drawing labels ‘over’ objects in 3D Space using GUI.Box and camera.WorldToScreenPoint(object.transform.position). This works perfectly fine - the labels appear on top of the objects and everything is fine. However, here comes the problem: When I ‘turn my back’ to the object, i.e. if the camera isn’t looking at it anymore, the Label/the GUI.Box still appears on the camera. I know this happens because GUIs can’t really be drawn in 3D Space and they are a special layer on top of the camera, but I can’t figure out how to fix it. Any ideas?


The z-coordinate of the vector you get from WorldToScreenPoint gives the distance from the camera. If its <0, its behind the camera. Then don’t draw it.