Strange behaviour with polygons

Mar 14, 2011 at 7:20 AM

Hi guys, have been playing around with the engine today figuring things out before I start using it. I am seeing some weird behaviour I don't understand.

If I create a polygon with the following vertices declaration, the first line works as expected, but the second line doesn't.

// Produces expected behaviour
Vector2[] vertices = { new Vector2(0, 0), new Vector2(0, -10), new Vector2(30, -10), new Vector2(30, 0), /*new Vector2(25, 0),*/ new Vector2(15, 5), };

// Produces unexpected behaviour
Vector2[] vertices = { new Vector2(0, 0), new Vector2(0, -10), new Vector2(30, -10), new Vector2(30, 0), new Vector2(25, 0), new Vector2(15, 5), };

This can be seen in this image:

http://i55.tinypic.com/30lgl7n.gif

The expected behaviour image, the circle falls onto the platform and balances on the spike. In the unexpected behaviour image, the circle falls through the platform, catches in the middle of the platform and oscillates for a bit, then gets pushed out to the side.

What is producing this behaviour?

Mar 14, 2011 at 9:10 AM

The "unexpected" polygon is a concave polygon. Farseer expects your polygons to be convex.