Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Use PolygonCollider2D for flat surfaces

Discussion in 'Editor & General Support' started by Dustin27, Aug 14, 2019 at 1:18 PM.

  1. Dustin27

    Dustin27

    Joined:
    Nov 12, 2018
    Posts:
    5
    Hi,

    I got an flat surface described by a list of points. I want to give that surface a collider.

    Adding a PolygonCollider2D with these points causes the collider to be rotated 90 degrees.
    PolygonCollider2DFlipped.PNG
    I am also not able to rotate the collider through rotating the game object, because the collider just gets smaller but does not rotate.
    PolygonCollider2DFlipped2.PNG

    Is there a way to use polygon collider for my case?

    Kind regards
     
  2. Gambit-MSplitz

    Gambit-MSplitz

    Joined:
    May 16, 2015
    Posts:
    1,181
    Unfortunately 2D colliders can only stretch in the X and Y directions and does not have Z coordinates. As you've already seen, this means you cannot rotate a 2D collider so that it's points move on the Z axis.

    If you're making a 2D game and want to use 2D colliders, you will need to design the game to be viewed forward down the Z axis, and not from above down the Y axis.

    If you're making a 3D game, you need to use 3D colliders. 2D and 3D colliders do not interact, and will not trigger/move each other. You cannot make 3D physics involving 2D colliders.