Hello Guest

Author Topic: Multiple identifiable colliders for single sprite - Islands?  (Read 4944 times)

phildo77

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 31
    • View Profile
Multiple identifiable colliders for single sprite - Islands?
« on: April 20, 2012, 03:01:45 am »
I'm trying to figure out if I'm able to create multiple colliders that I can reference for different functionality on a single sprite.  Here's what  I'm trying to accomplish:

I have a single background that I want to interact with.
Exit Zones-I will have multiple polygon colliders that will trigger an "exit" from the scene
Click Zones-I need multiple polygon colliders that I'd like to register as "clickable" (raycast)
Move/Non-Move Zones-I need multiple polygon colliders that will act "no move zones"

So long story short, I need to be able to reference the collider by index or name so I know what type it is, etc.

I am able to do this outside 2dToolkit but I saw that I can add multiple collider areas using the "Island" feature in the sprite collection editor and wondered if 2dToolkit already gave me some of this functionality?

I am unable to find any discussion or documentation on the Island feature there so I'm guessing it is a new feature?  Can someone help me out with what this is for?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Multiple identifiable colliders for single sprite - Islands?
« Reply #1 on: April 20, 2012, 10:33:52 am »
No, you won't be able to do this. The polygon collider island feature will merge and optimize the final mesh for performance reasons - so you end up with one collider regardless of how many islands you have.

One example use for it is for a background with a few platforms on there. Each platform would be an island on its own.

In order to create multiple zones like you require, you'll need multiple colliders. I don't think theres any way around that (apart from hacky solutions like guessing from positions, etc)

Uttpd

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Multiple identifiable colliders for single sprite - Islands?
« Reply #2 on: June 19, 2012, 05:46:35 pm »
(noob alert) so since the editor only allows to draw one collider per sprite... And what would be the most efficient way to do apply multiple colliders to the same sprite?