Hello Guest

Author Topic: Box colliders Center&Size!  (Read 5473 times)

divertap

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Box colliders Center&Size!
« on: April 18, 2012, 01:04:59 pm »
Hi,

I'm getting crazy trying to add a box collider with a sprite. I set correct values for the collider but the box collider size and center are resized with wrong values when I play the scene. Why?

M.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Box colliders Center&Size!
« Reply #1 on: April 18, 2012, 01:59:47 pm »
What happens with the box collider is entirely dependent on how the sprite is set up. Bring up the sprite collection editor, and check the collider option.

If it is set to None - that means any collider you add will be moved far from the origin (this is so some frames of animation can have colliders, and others in the same sequence can be excluded). The size will be set to 0, and position offset far into the background.

If it is set to Unset - this means it will simply use whatever collider you set up.

If you set up a BoxTrimmed or BoxCustom collider, then what you set up in the editor will be set on the box collider component.

This is so you can change the scale of the object (using the sprite.scale parameter, and retaining dynamic batching), and still have the colliders update correctly.



If you want to set up your own box collider and never have it change, simply change the collider option in the editor to Unset, and everything should work as you expect.