Author Topic: Custom colliders?  (Read 2872 times)

hexaust

  • Newbie
  • *
  • Thank You
  • -Given: 14
  • -Receive: 1
  • Posts: 35
    • View Profile
Custom colliders?
« on: March 20, 2014, 05:41:54 AM »
Hello all, I am pretty new to NGUI and Unity and I've just started my first project and I have a question related to colliders (I think).


I am trying to make some tiles (isometric) and I'm not really sure how to add proper interaction, I made them as UISprites and attached Box Colliders, but as you can see in the picture the colliders overlap. How to treat this situation?

Do the Polygon Colliders 2D work with NGUI? I've tried to use the UIHitAlphaTest from http://www.tasharen.com/forum/index.php?topic=7824.0 and it works, but the thing is that the tiles should be invisible and I guess that won't work with UIHitAlphaTest.

I hope I'm being clear on what I'm trying to do/say.

Thank you.

hexaust

  • Newbie
  • *
  • Thank You
  • -Given: 14
  • -Receive: 1
  • Posts: 35
    • View Profile
Re: Custom colliders?
« Reply #1 on: March 20, 2014, 07:08:50 AM »
Ok, so I managed to do something and I have no idea if it's the right way, but it works. Basically I used box colliders and rotated them in 3D space to have some kind of isometric view. I am building a 2D game and I guess I didn't thought of using 3D related stuff.




Is that the right way to do it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Custom colliders?
« Reply #2 on: March 20, 2014, 12:42:26 PM »
That's fine. Just keep in mind that you can also set widget's hitCheck to filter events based on either math or transparent pixels within a sprite. Useful Stuff sticky post has an example of how to do the latter.