Search Unity

Feature Request Sprite Shape interiors

Discussion in '2D' started by BACALL, May 2, 2022.

  1. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    Hi, trying to make interiors (caves, rooms etc) with the Sprite Shape tool.

    Please let me know if this is already possible, trying to find a good solution for over a year now. If this feature isn’t available then I strongly need it. See picture below.

     
    Walter_Hulsebos and Pharan like this.
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    Hi, If you are using version 7.x and lesser, please see a quick demo on how this can be achieved using the Confirming Spline example with some modification to the Script. Enclosed is a quick demo and the required ConformingInvertedSpline.cs to achieve the desired result.



    From version 9.0 onwards SpriteShape package provides ability to generate custom geometry/shapes by completely replacing or adding on to the default SpriteShape generator script. We will be adding more samples for this version soon. Will post an update.
     

    Attached Files:

    Last edited: May 24, 2022
    wedgiebee likes this.
  3. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    Hi, thank you for the script!

    I followed the video but had some issues:
    1. For some reason my shape doesn’t align in the middle (like in your video). But increasing the “Outer Bound Size” in the ConformingInvertedSpline.cs script makes it less noticeable. (See first picture below)
    2. Biggest issue: Adding a Polygon Collider 2D to the “Bottom” child creates a nice Collider shape, almost how I want it. But there is no way to offset/expand the shape? (Dragging the “Offset” slider in the Sprite Shaper Controller doesn’t work). I want the the Collider shape to expanded so it reaches the “Top” parents silhouette. So the player walks on the ground. Adding a Polygon Collider 2D to the “Top” layer creates a shape that fills the room, which is no good, but offsetting works. (See second picture below)
    So close now, very happy to finally see this!



     
  4. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    @Venkify Did you ever have to chance to read my post? All suggestions are appreciated
     
  5. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    I believe the simple demo was done with object at origin (0,0,0) .. Will take a look.

    Offset usually is meant to resolve such issues actually. However you can also try Legacy/Geometry collider located in SpriteShape Extras.
     
  6. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    87
    If I center the pivot, everything is finally in the middle... For anyone wondering I got a script from a previous post, don't remember the guy, but he made a script that centers the transform of the Sprite Shape.

    Tried every setting / combination in the Legacy Collider on the "Bottom" game object, with no good results. The "Geometry collider" unfortunately doesn't have an offset setting.

    Kind of found something that's in the right direction, but it's still no solution: If I increase the offset in "Simple 2" (Sprite Shape), which belongs to the "Bottom" game object, I can expand the borders, to even go past the Top borders. Unfortunately the PolygonCollider2D doesn't follow the offset-shape, it stays at the position before the offset was applied. I think a lot of us "Sprite Shape users" would be so happy to see and update, for this. Something that's holding my team back from doing a whole game with Sprite Shapes is the lack of "interior shapes".

     
    indie6 and wedgiebee like this.
  7. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Thanks this works fine! just wondering how can this be achieved in 9.0 and onwards packages?

    Also, I am getting this exception when using the method shown in the video:


    Code (CSharp):
    1. Fill tessellation (C# Job) encountered errors. Please disable it to use default tessellation for fill geometry.
    2. UnityEngine.U2D.SpriteShapeController:LateUpdate () (at ./Library/PackageCache/com.unity.2d.spriteshape@9.0.1/Runtime/SpriteShapeController.cs:562)
    Disabling fill tessellation fails to make it work, so can't disable it

    **edit**
    I am getting the same issue as above poster
     
    Last edited: Apr 4, 2023
  8. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    There cannot be any overlaps or intersecting edges in the given spriteshape. If the problem still persist, could you please post a sample scene or file a bug report ? Will take a look.