Hello Guest

Author Topic: Sliced Sprites as platforms with collision  (Read 4593 times)

Rybar

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Sliced Sprites as platforms with collision
« on: October 26, 2012, 02:13:16 am »
I'm trying to use sliced sprites as platforms, so I can use 1 simple box image for several different sized platforms, however I'm running into a problem with the box collider snapping back to a size thats much smaller than the committed dimensions for the sliced sprite.

Maybe they're only supposed to be used for UI/buttons?  Thanks for your help in advance.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sliced Sprites as platforms with collision
« Reply #1 on: October 26, 2012, 10:59:05 am »
No that should work properly. What is the collider set up on the sprite like?

attilam

  • Guest
Re: Sliced Sprites as platforms with collision
« Reply #2 on: November 19, 2012, 10:54:47 am »
Hello, I've had the same problem I think, I have a sliced sprite with a User Defined collider, but whenever I instantiate the prefab the collision of the sprite gets reset to something very small.

I'm using version 1.8 final 2, looking in tk2dSlicedSprite.cs:388 it seems like UpdateCollision() doesn't take into account what kind of colliderType is set, as a temporary fix I changed it like this:

Code: [Select]
new void UpdateCollider()
{
var sprite = collectionInst.spriteDefinitions[_spriteId];

if (boxCollider && sprite.colliderType == tk2dSpriteDefinition.ColliderType.Box)
{
boxCollider.center = boundsCenter;
boxCollider.extents = boundsExtents;
}
}

This seems to have solved the problem for me, for now...