# create a polygon mesh from a set of points

I have a set of points (empty objects), and I want to create a polygon based on their position. I tried the Triangulator class but when I use more than 4 points, I get weird results. Is there any other way to accomplish this?

I have also been looking on creating a spline of empty objects and create the mesh based on them and my desired width from center, but again with no luck.

I am looking for a solution for any of the above approaches. Here is a screenshot of the points.

well:

this is what u need to master, generally you have to generate the mesh by defining points, triangles, colors and uvs (i guess the last two aren’t so important now and you will understand it)

vertices are the points you have (coordinates are local to the mesh pivot)

triangles is 3x longer then vertices array and it’s array of INDEXES from the vertices array (not values)

and then u just give those two arrays to the mesh (after clearing the mesh or creating new)

``````Mesh mesh = GetComponent<MeshFilter>().mesh;
mesh.Clear();
mesh.vertices = new Vector3[] {new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 1, 0)};
mesh.uv = new Vector2[] {new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1)};
mesh.triangles = new int[] {0, 1, 2};
``````