x


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! =]

more ▼

asked Jul 16 '12 at 05:36 PM

ronaldosilva gravatar image

ronaldosilva
34 3 7 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 16 '12 at 05:41 PM

Meltdown gravatar image

Meltdown
5.6k 18 25 49

Thank you! =)

Jul 16 '12 at 06:50 PM ronaldosilva

If an answer helps, please upvote and mark as answer so we know your question is answered.

Jul 16 '12 at 06:51 PM Meltdown

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.

Jul 17 '12 at 03:24 PM ronaldosilva
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x66

asked: Jul 16 '12 at 05:36 PM

Seen: 321 times

Last Updated: Jul 17 '12 at 03:24 PM