x


OnMouseOver with multiple colliders

I have an object with 2 children : Radius and MouseDetect. They are both sphere colliders. MouseDetect is smaller than radius, and I need to detect whether the mouse is over MouseDetect. OnMouseOver doesn't work in that case (only the outer sphere collider triggers even though both spheres are Triggers).

I tried raycasting with a layer mask on the outer sphere, but it masks the whole object.

Any advice would be greatly appreciated.

Thanks!

more ▼

asked May 23 '10 at 09:39 PM

Jeremy 2 gravatar image

Jeremy 2
57 5 5 12

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

1 answer: sort voted first

Setting the two colliders to different layers should let you pick the correct one with ray casting. You can also do it with tagging and physics raycast all but the layers option is faster. (You have to write your own mouse over code in both cases)

more ▼

answered May 23 '10 at 10:11 PM

spinaljack gravatar image

spinaljack
9.1k 18 31 91

Thanks, it worked!

May 23 '10 at 10:37 PM Jeremy 2
(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:

x1707
x986
x15

asked: May 23 '10 at 09:39 PM

Seen: 1697 times

Last Updated: May 23 '10 at 09:50 PM