- Home /
Can I do isVisible for a specific camera?
According to the docs renderer.isVisible becomes true if the objects renderer is visible by any camera. How do I make it only true if visible by a specific camera?
Answer by Grimmy · Oct 07, 2010 at 11:49 AM
Okay well it actually 'just works' as long as the cameras are set to render different layers.
Basically 'isVisible' already takes into account the object culling mask..which I didnt realise.
It's more than that. "Visibility" just means whether it gets sent to the GPU to be rendered. It may then be occluded by objects that are closer to the camera. http://forum.unity3d.com/threads/34225-Are-OnBecameVisible-and-OnBecameInvisible-named-poorly?p=222221
Yeah I see. I'll need to write something to make sure the object is also facing the camera and not hidden by other objects as well as'being rendered by the camera/sent to GPU' :)
Also be aware that this isVisible is true if the editor camera can see that object. This is a pain when you want to use this variable for game logic like an enemy not shooting at the player unless they are on screen.