Hello Guest

Author Topic: Help, tk2d is beign a control freak with my collisiders!  (Read 5392 times)

Dajuice

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
Help, tk2d is beign a control freak with my collisiders!
« on: June 06, 2013, 04:22:30 pm »
I have 2D Toolkit 1.92 final and I have two problems that are a result of one feature of tk2d.
It seems that even when I set the sprite base's Collider Type to "User defined" in the sprite collection, it wants to control the collider.

I'm trying to have buttons that have a collider larger than the graphism, so I manually add a Collider, then I enlarge it, but here's what happens:
If I check the "Create Box Collider" checkbox, the collider becomes adjusted to graphism, not good.
If I uncheck it, the collider simply disappears... forever, even in the editor.

And I have a button that I need to swap the graphism, when the create box collider is checked, it "works" (even though the problem above occurs), when it is unchecked, it destroys my dynamically created collider.

I'm using Sliced Sprites, if it is important...

Any way to nullify tk2d's control over the colliders? Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Help, tk2d is beign a control freak with my collisiders!
« Reply #1 on: June 06, 2013, 05:43:41 pm »
Yes its kinda important with the sliced sprites. Maybe it needs a third state - "User defined" on there. Basically these special sprite types (clipped, sliced and tiled) don't follow the usual rules with colliders, simply because they manipulate the geometry of the mesh.

Hint: Change the behaviour by editing UpdateCollider in those functions.
Code: [Select]
if (CreateBoxCollider) {
if (boxCollider == null) {
boxCollider = GetComponent<BoxCollider>();
if (boxCollider == null) {
boxCollider = gameObject.AddComponent<BoxCollider>();
}
}
boxCollider.extents = boundsExtents;
boxCollider.center = boundsCenter;
} else {
//#if UNITY_EDITOR
// boxCollider = GetComponent<BoxCollider>();
// if (boxCollider != null) {
// DestroyImmediate(boxCollider);
// }
//#else
// if (boxCollider != null) {
// Destroy(boxCollider);
// }
//#endif
}

Dajuice

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Help, tk2d is beign a control freak with my collisiders!
« Reply #2 on: June 06, 2013, 06:54:50 pm »
okay thanks, yeah that's what I did, commented out all of UpdateCollider, but that would be great to leave control to the dev in one way or another, like you said ;)