Author Topic: Overlapping box colliders causing trouble  (Read 4597 times)

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Overlapping box colliders causing trouble
« on: May 28, 2013, 08:09:21 PM »
I've been struggling with this for a week and I can't get it to work because of some weird behavior in NGUI. Perhaps someone here can help. Here's a simplified explanation of my problem.

I'm having overlapping box colliders on an panel - one larger one encompassing the rather large panel, and another one in front of it for a tooltip text when hovering over a specific area of the panel. This second one is routed to a different onHover function using a delegate. The problem I am having is that hovering over the collider for the tooltip will also generate an OnHover event with a FALSE parameter for the other collider, and there is no way to tell which of the two boxes created the actual event. The gameObject triggered by OnHover() always reports the underlying, large panel box collider as the tripped collider.

For me this causes a can full of problems because I need to rely on various colliders acting independently for some of my GUI elements to function properly, so I was hoping someone might be able to help me sort this out. Is there a way to prevent the top collider to send an OnHover( false ) to the underlying one?
« Last Edit: May 28, 2013, 08:21:25 PM by StridingDragon »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Overlapping box colliders causing trouble
« Reply #1 on: May 29, 2013, 12:02:35 PM »
Different collider = different object as far as the UICamera is concerned. I advise getting rid of the 2nd collider, and instead write some custom logic that will calculate the area on your original collider.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Overlapping box colliders causing trouble
« Reply #2 on: May 29, 2013, 12:10:02 PM »
Since I have not only a second, but a third, fourth, fifth, sixth… 12th collider on that panel, that is not really a desirable option. As I mentioned in my post, I simplified my problem for illustrative purposes but there is a lot more going on. Doing a collision detection within the collision detection doesn't really seem all that sensible an approach. After all, that is exactly what I expected OnHover to do.

I still do not understand why the collision is trickling down from the top collider to the bottom collider? Why would the logic turn off the underlying collider? After all, the mouse is still over it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Overlapping box colliders causing trouble
« Reply #3 on: May 29, 2013, 12:11:45 PM »
There is no "trickling down". The only bubbling of events that happens is the one that you set up yourself using delegates, but even then it still treats different colliders as different objects.

This problem is addressed correctly by the new event system that will ship with the upcoming GUI solution. Until then, nothing I can do.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Overlapping box colliders causing trouble
« Reply #4 on: May 29, 2013, 12:22:32 PM »
Thanks, Michael. I'll try to find a work-around, probably using the bounds of the large panel to determine if it's been triggered with a FALSE event while he mouse is still on top of it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Overlapping box colliders causing trouble
« Reply #5 on: May 30, 2013, 12:07:31 AM »
I actually have all the math required to perform a raycast into the screen and determine a list of widgets hit underneath. I had to do it on the editor side already (in NGUIEditorTools), so I can add similar logic for run-time in the next update.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Overlapping box colliders causing trouble
« Reply #6 on: May 30, 2013, 12:24:45 AM »
That would be a god-send, really!  Thank you so much!!!