This project has moved and is read-only. For the latest updates, please go here.

Assertion Failed when adding floor bodies [SOVLED]

Topics: User Forum
Apr 10, 2013 at 12:19 PM
I'm trying to create a floor. I use a separate class floor the map of the game. The class adds bodies with textures to a List and draws them. But this caused a assertion failure:

at FarseerPhysics.Dynamics.World.SolveTOI(TimeStep& step)
at FarseerPhysics.Dynamics.World.Step(Single dt)
at Athyl.Game1.Update(GameTime gameTime) in \edunet...\Athyl\game:line 176

Line 176 is the world.Step(0.033333f);

The map class:
class Map
        List<DrawableGameObject> ground = new List<DrawableGameObject>();

        public Map(World world, Texture2D texture)
            for (int i = 0; i < 32; i++)
                DrawableGameObject floor = new DrawableGameObject(world, texture, new Vector2(40, 40), 100, "ground");
                floor.Position = new Vector2(i * 40, 680);
                floor.body.BodyType = BodyType.Static;

        public void Draw(SpriteBatch spriteBatch){
            foreach (DrawableGameObject dgo in ground)

Any ideas?
Apr 11, 2013 at 9:29 AM
Messed around with the code and found that if the number of bodies is less than 2, it works fine. More than 2 and I get the assertion failure...
Apr 11, 2013 at 11:35 AM
Okay, so I studied the problem even further, and I've come to the conclusion that is does not have anything to do with List or separate classes. It is whenever I try to add more than two static bodies.
Apr 11, 2013 at 4:03 PM
Found the problem! Someone at stackoverflow told me to remove
Debug.Assert(typeA == BodyType.Dynamic || typeB == BodyType.Dynamic);
In World.SolveTOI, line 1099. I don't know what good this throw is for, but now it works!