Hello Guest

Author Topic: Detecting polygon collider islands  (Read 4589 times)

Copywright

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 33
    • View Profile
Detecting polygon collider islands
« on: December 01, 2012, 02:35:29 am »
Hey,

I'm trying to have specific parts of a sprite under a collider, and detect that collider for scripting purposes. I want to use this for side-scrolling beat-em-up, so what I'm looking for is a collider island for the face, legs, and the back. Can this be done, or is this not implemented as of yet? And are there any alternatives (relatively new to Unity)?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Detecting polygon collider islands
« Reply #1 on: December 01, 2012, 07:03:52 pm »
I wouldn't do it like that at all. You could possibly detect islands, but concave mesh colliders don't collider with other concave mesh colliders in Unity, making it not very useful in this case - you cant have a convex collider with 2 islands. The island stuff is relally useful for backgrounds and such, but not really useful at all for moving and colliding objects like this.

So first question first - in your beat em up - are your characters just one sprite, or built out of smaller sprites for head, torso, etc?

The best solution here looks like it'll be something whereby you use multiple boxes to approximate different parts.

Copywright

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Detecting polygon collider islands
« Reply #2 on: December 01, 2012, 10:23:47 pm »
Now that you mention it, I do plan to have them be separate parts in the future (waiting for 2d animation suite Spriter to release w/ 2DTK plugin), but as of now, they're all one sprite. Is it possible to create these boxes within the 2DTK editor, or will I create them another way?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Detecting polygon collider islands
« Reply #3 on: December 01, 2012, 11:04:28 pm »
At this point there isn't any way to draw multiple colliders into one sprite, I'm afraid. You'll have to roll your own solution for that.

Edit: Create the colliders as children to the main sprite, and make sure the main object alone has a rigid body. That will make the children a compound collider.