Search Unity

Optimize PolygonCollider2D?

Discussion in '2D' started by daqs, Apr 25, 2015.

  1. daqs

    daqs

    Joined:
    Apr 5, 2015
    Posts:
    2
    Is there anyway to optimize the use of PolygonCollider2D? I'm adding an PolygonCollider2D via C# script to a very odd looking image and this creates 200+ vertices.

    Since I need to add the PolygonCollider2D component via script and not manually in the editor, I don't see a way I could optimize the collider. Can I manually edit the vertices? is that going to take a long time? is that even an optimized way of doing it? do you recommend an alternate solution?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use PolygonCollider2D.SetPath, along with .pathCount, to create whatever you want.

    --Eric