# LibGDX: Is there a maximum amount of vertices for a PolygonShape?

When you use PolygonShape.set(Vector2[] vertices), is there a limit of vertices of the array which is passed to the method?

Calling set on com.badlogic.gdx.physics.box2d.PolygonShape calls set on org.jbox2d.collision.shapes.PolygonShape, which does check the Settings.maxPolygonVertices (see PolygonShape source).

Thus, unless you've set org.jbox2d.common.Settings.maxPolygonVertices to something yourself, the number of vertices needs to be between 3 and 8 (inclusive) as the default is set to

/**
* The maximum number of vertices on a convex polygon.
*/
public static int maxPolygonVertices = 8;


Be careful about changing that number as it has an impact on performance.

Method that you mentioned looks like this:

public void set (Vector2[] vertices) {
Vec2[] v = new org.jbox2d.common.Vec2[vertices.length];
for (int i = 0; i < v.length; i++) {
v[i] = new Vec2(vertices[i].x, vertices[i].y);
}
shape.set(v, v.length);
}


Other methods in PolygonShape and her parent - Shape don't have the length limits too. I'm 100% sure that PolygonShape has no limit of vertices :_)