# Farseer: How can I break a body into multiple pieces?

I created a breakable body but the pieces are not flying around if the ball touches it. What is wrong? Why is the breakable body not breaking into pieces?

I made a video and I enabled debugview, so you can see the bodies:

http://www.vidup.de/v/ihW2L/

//create the breakable body
BreakableBody Polygon;
List<Vertices> list = new List<Vertices>();
Vector2 _origin;
float _scale;
uint[] data = new uint[PolygonSprite.Width * PolygonSprite.Height];

PolygonSprite.GetData(data);
Vertices textureVertices = PolygonTools.CreatePolygon(data, PolygonSprite.Width, false);
Vector2 centroid = -textureVertices.GetCentroid();
textureVertices.Translate(ref centroid);

_origin = -centroid;
textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f);

list = BayazitDecomposer.ConvexPartition(textureVertices);
_scale = 1f;
Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale;
foreach (Vertices vertices in list)
{
vertices.Scale(ref vertScale);
}

Polygon = new BreakableBody(list, world, 1);
Polygon.MainBody.BodyType = BodyType.Static;
Polygon.MainBody.Position = new Vector2(graphics.GraphicsDevice.Viewport.Width / 200f, graphics.GraphicsDevice.Viewport.Height / 200f + 1.15f);
Polygon.Strength = 2;
Polygon.MainBody.CollisionCategories = Category.Cat11;

• You need to learn how to debug small programs. Take a very close look at PolygonTools.CreateRectangle (look at the Farseer source, read the doc comments). What parameters does it take? With the parameters you are giving it, will it output what you expect? If you step through in the debugger and inspect the output, does it match your expectation? What about the overload that takes more parameters - are they parameters that you need to set? Repeat the process for new BreakableBody. You will find the bug. – Andrew Russell Apr 6 '14 at 2:42
• In the original those loops are intended to set the center position of each of several rectangles to different values. But the original doesn't have valid parameters (as the writer indicated: "off the top of my head"). Like I said: check the overloads for CreateRectangle. There is a version that takes both half-sizes and a position. – Andrew Russell Apr 8 '14 at 12:51