- Home /
How to know if an object is ocluded
I want to make a script that uses the OnBecameVisible/Invisible to control the roof fans of my level. When I turn and see the fan I want it to be activated but only if the fan is not occluded by a wall or something. Is there a way to verify if an object is totally visible by the main camera? Thanks any help! =]
Answer by Meltdown · Jul 16, 2012 at 05:41 PM
If you are using Occlusion Culling (Pro only), using Renderer.IsVisible may well work.
If not you would have to do multiple rayCasts towards your fans and determine if they were hit or not, using your walls/obstacles in the Layer Mask.
If an answer helps, please upvote and mark as answer so we know your question is answered.
Actually, its not working =/ I put a rotating cube behind a wall, and event if I am looking at that wall, the cube is still rotating. Looks like if the cube is in the frustum view, its processed as visible anyway.
Your answer
Follow this Question
Related Questions
"Tree Soft Occlusion Leaves" shader has been shafted? 0 Answers
Computational cost of using many Triggers (occlusion culling) 1 Answer
Combine Mesh, Occlusion Cull, Lightmapping All In One 1 Answer
Unity 5 Parallax occlusion artifacts 1 Answer
Explain the use for Occlusion Area? How is this different from regular Occlusion Culling? 2 Answers