Shape PolygonCollider2D

Hello everyone, i’m trying to shape PolygonCollider2D in my game for detecting collision of the player, this picture is self-explanatory:

I have 3 waypoints, and in this 3 gameobjects i want to create a box for player trigger, but i can’t shape nicely the collider(documentations of unity is poor).

And this is the code:

PolygonCollider2D polygonCollider = GetComponent<PolygonCollider2D>(); //reference of polygonCollider

polygonCollider.points = new Vector2[waypoints.Count * 2];    //set double points for up and down from waypoint

Vector2[] tempPolygon = polygonCollider.points;     //temp variable

int x = 0;    // temp variable for get right waypoint(external array)
for (int i = 0; i < tempPolygon.Length - 1; i = i + 2)
{
    //set point from waypoint to up
    tempPolygon *= new Vector2(waypoints[x].localPosition.x, waypoints[x].localPosition.y + polygonHeight);*

//set point from waypoint to down
tempPolygon[i + 1] = new Vector2(waypoints[x].localPosition.x, waypoints[x].localPosition.y - polygonHeight);

//go to next waypoint
x++;
}

//update all points
polygonCollider.points = tempPolygon;
Thanks in advance! =)

Never mind, i found a solution… just add max 4 points, and one collider component, for every couple of waypoints, and the game is done! :smiley:

question is answered. Thanks ( i just read it over and browsed reference for you )

please write your answer as an Answer and mark it as correct thanks.
I found a solution! just add for every couple of waypoints one component and set max points of 4, then build your shape :slight_smile: