Search Unity

4.5 - 2D colliders rotated sideways to world

Discussion in '2D' started by golonko, May 29, 2014.

  1. golonko

    golonko

    Joined:
    Nov 6, 2012
    Posts:
    13
    Hello,

    Since the introduction of 4.5 and 2D colliders following rotation of the rigid body I have a pretty big issue.
    I'm using a 3D character model in my game and it is prepared in a way that i have to rotate it 90 degrees in Y axis, so it faces in the correct direction. I'm also using mecanim animation to move the character around.
    I'm attaching 2D rigid body and 2D colliders to it, so it works with the rest of my 2D game. The colliders are used for physics as well as for input detection.
    It used to work fine until 4.5 changed the behaviour of colliders attached to rigid bodies.
    In the new version my colliders are rotated together with the model, and since they are 2D, the resulting width is nil.
    It's pretty darn hard to hit the colliders with touch or mouse event now.

    Does anyone know of a simple solution to this?
    So far i've tried a few things:
    1. moved the rigidbody and colliders to a parent object
      the result is that the child containing the animator is moving, but the parent stays in place, and the physics is calculated for the parent
    2. as above, but also move animator to the parent
      animation does not move the object at all
    3. moved the colliders to a child object and rotate them -90 degrees in Y axis
      does not work - the colliders follow the parent rigid body orientation and ignore the fact they are in a different object with different rotation
    4. The only other solution that came to my mind was to create a separate object with a rigid body and link it to my character with a joint, but I can't seem to find any non stretchable joint that would propagate a collision from one rigid body to the other.

    Am I missing something here?
    I know the best solution would be to rotate the model before exporting, but that's not really an option for me.
     
  2. Fubeca

    Fubeca

    Joined:
    Jul 21, 2013
    Posts:
    41
    I am having the same issue, for the same reason. What I've done that seems to work better is create a parent that is really just a placeholder gameobject, and move the colliders to be children of that. That works for most of my colliders. But I still have a problem with my models that I've attached 2D colliders to the various extremities of the 3d model, and those all fail when the model is rotated (which is always, since I have to rotate it to get it to stand up straight).

    I really want to know if this new rotated collider to be infinitely small is a feature, or a bug.
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497