Search Unity

SpriteShape fill, corners and collider issues

Discussion in '2D Experimental Preview' started by CDF, Sep 19, 2019.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    775
    apologies if this is already a known issue. But I'm struggling to create my sprite shape with corners, fill and colliders that match the shape edges.

    Here's what I desire:
    spriteShape_desired.png

    Here's a video showing the issues I'm facing:


    Basically I'm unable to create the desired shape because:
    • Fill shape is strange, doesn't match the points defined, seems to bulge instead of just scale up/down
    • Collider isn't correct when using linear edges. Collider is better when using broken edges, but still has strange angles at edges
    • Corners don't show up when using broken edges, and some very strange rendering artifacts can be seen
    Collider issue when using linear edges:
    spriteShape_collider.png

    Rendering issues when using broken edges (where are the corners?):
    spriteShape_broken.png

    Are these issues known? Or is this just a limitation of Sprite Shape?
     
    Last edited: Sep 19, 2019
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    205
    Thanks for reporting. The fill shape will try to match the outline including the corners so it does not overlap the corners itself. However at certain points as mentioned above, the points seem to bulge. This is a bug and we will fix it asap.

    We provide multiple collider generators to match different use-cases. Please check this post :
    https://forum.unity.com/threads/spriteshape-preview-package.522575/page-6#post-4479055
    and try GeomtryCollider for more accurate results.

    By design, corner sprites are only considered on Linear points.
     
  3. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    205
    @CDF Can you also please provide the version of the package you use and send us a simple repro project as well ?
     
  4. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    775
    Sure, attached a zip of the project.
    Unity Version: 2019.2.4f1
    Sprite Shape: 2.1.0 preview.11
    LWRP: 6.9.1

    Let me know if you need a bug report submitted as well.
     

    Attached Files:

  5. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    775
    Ok, I'll check that out. But I do think this is a bug:
    nsf9IYrXtR.gif
    Doesn't make sense why only these 2 points don't scale with the rest of the points.
    Any why those 2 points even exist? The entire shape is made of linear edges, there should be no points at those locations!

    EDIT - I checked out this thread: https://forum.unity.com/threads/spriteshape-preview-package.522575/page-6#post-4479055
    I'm using 2019 version so I assume the Geometry collider generator is included? Because I see no option to "Generate Collider" in the menu bar.
     
    Last edited: Sep 19, 2019
  6. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    775
    Some more collider strangeness:
    collider_settings.gif

    When optimize collider is off, the last edge is not created, and many points exist. Strange that when optimize is false, a seemingly random distribution of points exist. The entire path is linear, so these extra points don't make sense, unless somehow, internally it's thinking the path is a curve.
     
  7. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    205
    Thanks for the update. Will take a look. Regarding GeometryCollider please install SpriteShape Extras from the packagemanager UI.

    spriteshape_extras.png
     
  8. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    205
    Just took a look at the Project. The issue with the fill texture seems to be due to a bug in LWRP in 2019.2 where the ordering of the Fill Geometry is wrong.
    This has been fixed in the latest 2019.3 and URP.
    In 2019.2, as a workaround you can also use two different materials (using same shaders) for fill and edge that should also fix the issue.

    Regarding the Collider, the default collider is built to be fast to be usable at runtime. However additional scripts are provided to generate colliders for various use-cases. In the demo attached, the Legacy collider generated is being used.

    Here is a quick demo :
    Generating Colliders from Extras Scripts.gif
     
  9. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    775
    Ah ok, thanks for checking it out and providing a workaround.
    2019.3 still too early in development for me to switch.
    I assume LWRP 6.9.1 is the last version and won't receive any fixes?