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

Having an issue with collisions

Topics: Developer Forum, Project Management Forum, User Forum
Oct 4, 2014 at 10:38 PM
I am creating a 2D Multiplayer game and trying out the Farseer physics engine to do collision detection, but I am running into an issue where it's not colliding multiple times with the same object. For example if object A collides with object B, I cannot collide with object B until I collide with object C first. I am not sure if its a setting or I am doing something wrong here.

The function below is what I use to route all the incoming entities into the world to perform simulations on.
        public Body BodyFactory(Vector2 position, float size = 32f, object userData = null)

            Body newBody = FarseerPhysics.Factories.BodyFactory.CreateCircle(_world, ConvertUnits.ToSimUnits(size / 2.0f), 1f, ConvertUnits.ToSimUnits(position), userData);

            newBody.BodyType = BodyType.Dynamic;
            newBody.IgnoreGravity = true;
            newBody.Friction = 0.3f;

            return newBody;
I made 2 walls to collide against.
            Vector2 startVector = ConvertUnits.ToSimUnits(new Vector2(wall.X, wall.Y));
            Vector2 stopVector = ConvertUnits.ToSimUnits(new Vector2(wall.X + wall.Width, wall.Y));

            FarseerPhysics.Factories.BodyFactory.CreateEdge(_world, startVector, stopVector,
                "North Wall").BodyType = BodyType.Static;

            startVector = ConvertUnits.ToSimUnits(new Vector2(wall.X, wall.Y));
            stopVector = ConvertUnits.ToSimUnits(new Vector2(wall.X, wall.Y + wall.Width));

            FarseerPhysics.Factories.BodyFactory.CreateEdge(_world, startVector, stopVector,
                "West Wall").BodyType = BodyType.Static;
I just have an event handler for the collision for debugging:
        bool Boundary_OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
            Console.WriteLine(string.Format("{0} is colliding with {1}", fixtureA.UserData, fixtureB.UserData));

            return true;
Here is the behavior I am observing on the client side. If any other code is needed please let me know I think those were the main pieces. Thanks in advance for any help.
Marked as answer by lakedoo23 on 10/4/2014 at 8:19 PM
Oct 5, 2014 at 4:19 AM
Okay, so it appears that setting the Position directly messes up the collision detection, I suppose I will use ApplyLinearImpluse to move the character, that seems to work fine.
Oct 8, 2014 at 1:08 PM
Thanks for your post in my discussion

Interesting - I suspect my issue with collisions may be similar to yours. When I get the chance I will have to re-visit development of my game, which is currently on the back burner. Take a look here if you are interested as it does show game play.

The YouTube video is located here:

Peter D