Search Unity

Bug [SpriteShape] I think the generation of edge colliders is broken?

Discussion in '2D' started by Baste, Nov 18, 2020.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    Here's a gif:

    0zRTHQCpWK.gif
    I just took the sprite shapes from the "3 Platformer" sample, and replaced the polygon collider with a ledge collider. As you can see, they get completely confused by corners, and create a reverse triangle instead of just a corner.

    If I "Optimize Collider", the problem is hidden, except in the offset range of 0.3 to 0.45, where there's a "lip" that sticks out to the right. That's the offset range that I'd want to use, so that's an issue.



    I tried the other colliders from the extras package, since that's been suggested by devs. The GeometryCollider only supports PolygonCollider2D, doesn't allow me to define the offsets, is slow, and generates pretty bad colliders:

    upload_2020-11-18_12-35-7.png

    The LegacyCollider is the only one that seems to not have bad artifacts, but a) it's named "legacy", so you probably think it's bad somehow? and b) it's generating a lot more points than the default one. I might go with the legacy one for now, since I get good results:

    upload_2020-11-18_12-43-49.png

    But the big questions here is "is the behaviour of the first gif a bug?" and "Why does the geometry collider even exist when it gives such bad results?" and "Why are there three different ways of making colliders?"
     
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    @Baste Thanks for the post. Please submit a bug report. Will take a look asap.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    1293760

    That's with Unity 2020.1.13f1 and the included version of SpriteShape (4.1.4).