Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unreliable Physics2D in Unity 5

Discussion in 'Physics' started by helios, Mar 13, 2015.

  1. helios

    helios

    Joined:
    Oct 5, 2009
    Posts:
    305
    Hello Melv,

    Unity Bug folks sent me a message saying the one-way collider stuff was fixed (bug 683964) in 5.1.1p2. I saw it in the release notes, but unfortunately the bug is still happening - in fact, it's even worse as the side-collision now happens regardless of what the player's Y velocity is (before it was only happening when Y was negative). You always collide with the sides now, when it should never. Any idea what's going on? Thanks.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    1,959
    Have you noticed the new property of 'Surface Arc'?
    NewPlatformEffector2D.png

    The 'Surface Arc' property defaults to 180-degree and has a gizmo to represent it. This arc defines the (non-one-way i.e. always solid) surface and is used by comparing the collision normal angle of your object touching it. If it's within this arc then it's not one-way, if it's outside of it then it's one-way (assuming one-way is on).

    Therefore, the default 180-degree arc, centered on the local 'up', means you get a solid surface spanning from the local-left, clockwise to the local-right thus verical sides are solid with that value. Simply reduce that by 1-degree to not include vertical sides; for edges, you probably only want a few degrees i.e. a collision normal of local-up only so reduce it to a few degrees although 0 degrees will work.

    Note that the one-way behaviour now doesn't rely on velocity of any kind as it was too unstable. Bodies moving across a surface move with tiny variations of vertical movement and this is hard to control in a stable way, especially when more complex set-ups were tested. Now, it's entirely based upon the collision-normal which is both stable and easily configurable against hence the new 'Surface Arc'.

    This thread has a lot of different topics so I would suggest that we either use a new dedicated thread or feel free to message me directly and I can help you out there.
     
    Last edited: Jun 28, 2015
  3. helios

    helios

    Joined:
    Oct 5, 2009
    Posts:
    305
    Wow, I certainly did not notice that. Apologies - and thanks for the information, everything is perfect now.

    I'll use a new thread in the future. Thanks again.