Check if a camera is looking at an invisible object

I know how to check if the renderer is visible, but I want to know if a camera is looking at an object WITHOUT a renderer enabled. I don’t want an object to enable rendering when a camera is looking in its direction. But when I use

if (boolName && !renderer.isVisible) { renderer.enabled = true; }

it renders anyway because renderer.enabled is false when that code is executed. This can be achieved by complex raycasting, but I don’t know how to do that and I’d rather not add 50 extra lines of code. Thanks.


To check whether a point can be seen by a camera you can check whether that point, transformed using WorldToScreenPoint has a x value between the range of 0 and the screen width (Screen.width), a y value in the range 0 to the screen height and a positive z value.

Hope this helps,

PS: If you don’t know how to code that, I suggest you learn coding before you try something like this :wink: