Search Unity

Collider overlap/squash when force applied in certain directions.

Discussion in '2D' started by jameskyle, Oct 27, 2014.

  1. jameskyle

    jameskyle

    Joined:
    May 7, 2013
    Posts:
    37
    I have an issue with box colliders. I have enemy characters whose collider is just a box. Rigidbody 2D is also applied. I have a player character whose job it is to push these enemies around,

    When the player pushes enemies coming from the left side of the screen the enemies barely overlap, if they even do at all. The box colliders seem very solid. This is as I would expect. When the player pushes enemies coming from the right ride of the screen however the box colliders overlap. The enemies seem to squash together.

    I had thought this would be because the enemy x scale on enemies on the right was set to -1. The effect remains when I rotate the y axis by 180 degrees, so I'm assuming neither scale or rotation are the issue. I haven't seen anything in the Physics 2D project settings that would indicate a problem.

    The enemies at either side of the player are identical, so I have no idea why this is happening. The only difference is that the enemies of the either side is the force applied (the same, inverted to move them towards the player at the same speed, then velocity constrained to stop them moving too fast.) The squashing effect doesn't bother me, but I need consistency between the two sides and I'm at a loss on how to achieve this.
     
  2. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    That's weird. Can you submit a bug report on this? Knowing which Unity version you use and having a repro case will help.
     
  3. jameskyle

    jameskyle

    Joined:
    May 7, 2013
    Posts:
    37
    edut: I've removed the links that were below as they're no longer relevant.

    I've tried recreating the bug with little success. I'll continue to work on it but I'll put up a bug report and see if anyone can figure this out.

    My project relies quite heavily on commercial Asset Store plugins like Playmaker. If I'm making a bug report and uploading my project folder is it a good idea to upload these? I'd appreciate some clarification on this before I go uploading my project source and perhaps distributing commercial plugins illegally. ^_^

    In the meantime I've also uploaded to my Dropbox public folder a web player build that shows the issue, along with my failed attempt to recreate it. You can see in the first link what's happening to the enemy characters on the right and how it differs from those on the left. The prefabs are the same, the only difference being the velocity is mirrored and the Y rotation set to 180. I'm using the latest version of Unity as I hoped that this would help the problem.
     
    Last edited: Oct 29, 2014
  4. jameskyle

    jameskyle

    Joined:
    May 7, 2013
    Posts:
    37
    Oddly the enemies on the right react the same as those on the left when the player collides with them from the right (starting off-screen and hitting them in the same direction as it would the enemies on the left side.)

    I don't know what this means, but I thought it odd enough to mention.
     
  5. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    You can upload projects with asset store plugins via unity's bug reporting tool without fear.
     
    jameskyle likes this.
  6. jameskyle

    jameskyle

    Joined:
    May 7, 2013
    Posts:
    37
    I uploaded it on the 28th of October and I've been fiddling around with it since then with no luck until today. I think it's down to the character structure. He's made up of a game object with box collider 2D/rigidbody 2D that contains a hierarchy of sub-objects with animstions. One of the objects in the hierarchy is a shield, to which I'd attached a box collider. This box collider, in the default pose at least, begins intersecting with the base objects box collider. Though it's not intersecting with the player base box collider 2D at any point in the animations removing it seems to have cleared things up a lot. I'll just extend the root object's box to the shield's edge for player/enemy collisions, then set up a few extra colliders with physics layers adjusted accordingly to allow for separate collision detection for the shield, the player's vulnerable spots and the enemy projectiles.

    edit: To be clear, it doesn't seem to be completely cleared up but it is a lot less obvious.
     
    Last edited: Nov 10, 2014