Search Unity

Question Sprite Shape/Edge Collider with flat ends?

Discussion in '2D' started by zacharyhunterlund, May 28, 2023.

  1. zacharyhunterlund

    zacharyhunterlund

    Joined:
    Mar 7, 2021
    Posts:
    54
    Hello,

    I am trying to use Sprite Shapes to make these logs/branches that are flat on the ends. Here's what I'm talking about:

    This is what I have...



    ...and the red part here is the collider I want.


    My question is, how could I create a sprite shape collider like this, one that acts similar to an Edge Collider but with flat ends? Do I need to create a custom script for this?
     
  2. DanielTanBK

    DanielTanBK

    Unity Technologies

    Joined:
    Aug 20, 2019
    Posts:
    83
    Hello, yes, you would have to create a custom script for this.
    In the package's
    Sprite Shape Extras
    samples there is the
    Colliders
    scene showing a
    Legacy Collider
    script that works similarly. You could take that as a reference to create a simplified script to fit your needs
    Unity_kwE3sIVFVO.png