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

Body mass is different on collision.

Topics: Developer Forum
Jan 27, 2014 at 3:15 PM
When I create the Body, and set a mass, the printing shows the right float value. But once a collision occurs with another object, both object's mass resets to 0,25. Why is that happening?
//////////////CREATING STUFF//////////////
            model = new UnitModel();
            model.weight = 300f;
            model.velocity *= Util.pixelToUnit;
            model.stopVelocity *= Util.pixelToUnit;
            model.maxSpeed *= Util.pixelToUnit;
            model.body = BodyFactory.CreateRectangle(world, 50 * Util.pixelToUnit, 50 * Util.pixelToUnit, 1);
            model.body.BodyType = BodyType.Dynamic;
            model.body.Position = new Vector2(x*Util.pixelToUnit, y*Util.pixelToUnit);
            model.body.CollidesWith = Category.Cat1;
            model.body.Mass = model.weight;
            model.body.FixedRotation = true;
            model.body.OnCollision += Body_OnCollision;
//////////////COLLISION HANDLING///////////////
private bool Body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
            float massComponent = fixtureA.Body.Mass / fixtureB.Body.Mass;
            Console.WriteLine(massComponent); //prints 1
            Console.WriteLine(fixtureA.Body.Mass+"___"+fixtureB.Body.Mass); //prints "0,25___0,25"
            return true;
Any ideas? Thanks!