2
\$\begingroup\$

This is a part of map (it is a cave) of my LibGDX game (using Box2D): enter image description here

I would implement a PolygonShape as the black part of the map to prevent the whatever moves (for example a ball) inside the cave from leaving it.

This is an example of my PolygonShape like I would draw it (with 100 vertices): enter image description here

The problem is that Box2D doesn't allow me create it with not more than 8 vertices...

How can I fix this thing?

Sorry, my English isn't very good. :)

\$\endgroup\$
2
\$\begingroup\$

Polygon shapes are normally limited by the internal b2_maxPolygonVertices setting (in the C++ library code), which as of Box2D 2.3.2 is set to 8.

The other problem though is that polygon shapes must be convex. What you're were trying to use a polygon for though looks to be a concave shape. For concave, static (immovable), shapes, the Chain Shape is the way I'd go.

From your comment, it looks like you have since decided on using ChainShape too.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.