Hello Guest

Author Topic: Automatically generated collider is smaller than it should!  (Read 4522 times)

luispedrofonseca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Hi guys,

I'm currently building a platformer game using 2d Toolkit and for some reason the automatic box colliders that you can create on sliced, tiled and clipped sprites are a bit smaller than they should. See the screenshot attached.


Please notice that if I create a new project and try to do the same, everything works as expected. But unfortunately I can't figure out what could be different from my project to a new one that could influence the box collider creation. Any ideas?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Automatically generated collider is smaller than it should!
« Reply #1 on: July 26, 2013, 11:22:09 am »
No - I can't explain this at all. The collider bounds are generated from the bounds of the mesh, so it can't possibly be offset like that. Unless.... your scene view is perspective, and the bounds are actually offset back from the sprite itself so it looks smaller in perspective?

luispedrofonseca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Automatically generated collider is smaller than it should!
« Reply #2 on: July 26, 2013, 11:40:49 am »
Very weird indeed!

Unfortunately it's not a camera problem (as you can see in the screenshot attached).



I've stripped all my project content and created a test scene for you to inspect if you want. You can find it here:
Edit: removed link.

Please notice that I'm using the latest Unity Pro (4.2) on OSX.

Thanks for your help!
« Last Edit: July 26, 2013, 11:47:01 am by unikronsoftware »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Automatically generated collider is smaller than it should!
« Reply #3 on: July 26, 2013, 01:28:03 pm »
I just noticed that you changed the tk2d code in your project. This is what is causing the issue.

You've changed .extents to .size in the code. Either revert your changes, or upgrade to the 2.1 beta. The obsolete warnings are just that - warnings, you don't have to do anything about them. size = 2x extents, so simply replacing like that won't work.

luispedrofonseca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Automatically generated collider is smaller than it should!
« Reply #4 on: July 26, 2013, 03:53:21 pm »
You are right! Sorry about that!

I'll upgrade to the beta version to get rid of the warnings. ;)

Thanks!