Search Unity

Troubles with Unity 5 and 2D colliders

Discussion in '2D' started by Corum, Mar 14, 2015.

  1. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hi there. :)
    I have some problem with 2D colliders.
    Everything works as expected until 4.6.
    This strange behaviour occurs randomly in same 2D terrain conditions and same elements involved.
    Car stays on terrain profile but sometimes, alternatively, front and rear tires sink under the collider line, when it comes to a change of slope or a landing after the previous jump.
    Scenario includes:
    - CircleCollider2D to EdgeCollider2D;
    - isKinematic = false;
    - Static Sprite image.
    - No animations;

    edge_unity5_bug.PNG

    Any guess about it?
    Thanks.
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I just had practically the exact same thing happen.... circle collider against an edge collider, it spontaneously passed into the surface. The only thing stopping going all the way through was i happened to have another collider inside the circle (as a trigger).

    See here http://forum.unity3d.com/threads/why-is-this-sphere-collider-stuck-in-the-surface.310144/

    I am hoping, based on that this happened to you also, that this is a bug. I wonder if it has something to do with the fact that the circle collider spans multiple vertices in the edge collider, and this confuses the calculations? If your edge collider has a lot less points in it, does it stop it happening?
     
  3. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    Do you think colliders are dynamically reworked at runtime?
    I can appreciate their movement in frame-to-frame debugging within the editor, but it seems their geometry stays 'locked'.
    I think it's a clear bug, because the little game related to the screenshot is lovely running in production, on both Android and WP8 platforms, and it runs smoothly.
    I developed and tested it (46 days of overall work) using Unity 4.6, with no evidence of a collision problem like this.
    I mean, It is so huge to spot that cannot pass unseen under your nose. :)
    Many thanks for the other thread you linked. I'm going to follow that too.
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I don't know if regenerating colliders at runtime has anything to do with it. I tried a hacky fix where, if an inner circle collider was hit, it would try to disable the outer collider and re-enable it, to sort of force a recalculation, but this didn't work... although disabling/enabling some colliders in the inspector seemed to trigger a recall in some cases, but not all. This shouldn't be necessary though.

    I've only seen this spontaneously happen once, after quite a large number of test sessions, but it's worrying because if something like this happens in the game, and it puts my sphere into the surface like that, the player won't be able to complete a puzzle and their progress in the game will come to a complete stop.

    I can put the circle collider into the edge collider in the scene view, then hit play, and often it will just stay there and not correct itself. I am also not sure if it has something to do with two edge colliders being next to each other, and the sphere touching both at once or something.

    What puzzles me is that the collider can be embedded inside the surface like that and the physics engine is not correcting it, ever. In your case your surface is even flatter than mine - i wondered if it was like the influence from multiple edge vertices canceling each other out or something - i don't know if the physics system works like that or just has one contact point, and the sphere collider is not even all the way half-way into the surface. So at this point I hope it is a bug of some kind. I didn't know Unity were changing anything with 2d physics in Unity 5, but it appears many people have experienced various new problems.
     
  5. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    It's absolutely a bug.
    I have the start menu screen showing the car that continuously travels from left to right, falls down, respawns from left, and again.
    Same acceleration, same route, same way everytime.
    But sometimes, when my car spawns from the beginning coordinates, it crosses the terrain, falling down.
    Then it respawns, falling down, and again, and again...
    When the problem occurs, the terrain seems transparent forever, until I click it in the Objects Hierarchy.
    During this phase, I strangely get to make the terrain "rigid", and the car starts to run its surface as expected.
    If I keep the terrain selected, the problem barely occurs again.
    If something has changed in Unity 5 collisions management, I'd like to know, otherwise it's a bug.
     
  6. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    I shot a little video to explain what's happening in my case.
    As you can see, the problem occurs on a random basis, with no chances to force it in a deterministic way.
    What to do? Is this enough to open a bug report?
     
  7. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'd say so. It definitely shouldn't be happening sometimes and not other times, it should at least be consistent. I'd say it's a bug. When I changed my circle collider to a polygon collider with a circular shape, all the problems went away. So I think it's the circle collider interacting with the edgecollider that is bugged.
     
    Corum likes this.
  8. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    Thanks again for the info. At least we know how to patch awaiting a proper patch. ;)

    EDIT:
    I attach the packed project directory. Feel free to download and try it out into your Unity 5 environment.
    Maybe I did something wrong and just don't know what.
    Any comment or suggestion will be strongly appreciated.
     

    Attached Files:

    Last edited: Mar 16, 2015
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Yes, this is a bug that I fixed yesterday. It is waiting (amongst other fixes) for review then it'll go into the next available 5.0.0 patch release.

    Sorry for the problems this has caused.
     
  10. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Ok cool, always great to get confirmation if something is a bug or not. Phew! Looking towards the patch. Are non-pro (in the new licensing terms) folks able to access the patches or are they only for the paying customers?
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Yes, patches are available to all for free here. They are done weekly.

    Just to confirm that I have fixed the issue but unfortunately it missed this weeks 5.0.0 patch 2 so it'll go into next weeks 5.0.0 patch 3.
     
    Corum likes this.
  12. Corum

    Corum

    Joined:
    Jan 28, 2014
    Posts:
    17
    Hey @MelvMay,
    Many thanks for your clarifications. Looking forward to patch 3.
     
  13. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    In which version, do you found fix for this?

    Because in Unity 5.3.1p2, my sphere collider goes into mesh collider.

    do you have any idea how to fix this? I have already tried with collision detection to continuous.
     
  14. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Those are 3D colliders, not 2D colliders so have nothing to do with this thread. I would recommend posting your problem on the Physics forum.
     
  15. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
  16. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    I'm not on the 3D physics team. Hopefully one of those guys will see it and reply to you.