x


Light Colision

Hi! I'm still learning Unity, and in my work, I intend to simulate some kind of sensor light.

The idea is to have an area or spot where the light is directed, and I want to register the ammout of time a passing object stays under the light.

Do you have any suggestions or ideas for the best way to pull it off?

Thanks in advance!

more ▼

asked May 24 '12 at 12:49 PM

skitch gravatar image

skitch
15 3 7 9

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

1 answer: sort voted first

Model a rough cone (like 16 polys) that matches the light angle (I'm assuming this is a sweeping spotlight, not a stationary floodlight, or the solution would be trivial) with its origin at the point, make it a mesh collider trigger, parent to the light object, then check when the object enters the trigger and when it exits.

more ▼

answered May 24 '12 at 01:00 PM

Kiloblargh gravatar image

Kiloblargh
1.1k 35 57 74

Hmm, the light I want to use is static and it's supposed to be like a laser beam, so do you think if I add a capsule collider to the light I can have it detecting the colisions?

The passing object is a rigidbody with a boxcollider.

May 24 '12 at 01:40 PM skitch

I would use a ray cast if it is a lazer. cast the ray from the source light position to the target. I've had good results with that. go to the Unity docs and look into raycast. My advice with this would be to do the actual cast (which you will not be able to see) and for testing purposes also do a Debug.DrawRay which will show up in the editor. It's easy to set up, but also easy to make a mistake with. It's also a less CPU intensive solution for what you want to complete.

May 24 '12 at 04:45 PM torrente
(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:

x2584
x588
x445

asked: May 24 '12 at 12:49 PM

Seen: 346 times

Last Updated: May 24 '12 at 04:48 PM