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

FrictionJoints and Top Down Games

Topics: Developer Forum
Jan 25, 2011 at 3:39 AM

I have been struggling for a few days on how to implement friction for a top down game.  There seem to be examples in the 2.x framework that describe setting LinearDragCoefficient.  But this property does not seem to exist in 3.x or I am missing it.  I have seen recommendations to set LinearDampening, but when I do that the movement does not stop at 0, like friction would.  It starts moving my character backwards after 0 has been reached.  I believe that the correct approach would be using FrictionJoins but for the life of me I can't get them to work.

I have a body that I am applying a force to based on user input:

character fixture creation-

fixture = FarseerPhysics.Factories.FixtureFactory.CreateCircle(,Size.X / 2.0f, 1.0f, Position);
fixture.Body.BodyType = BodyType.Dynamic;
fixture.Body.Mass = 10.0f;
fixture.Friction = 0.5f;

character fixture update-

fixture.Body.ApplyForce(new Vector2(Velocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds, Velocity.Y * (float)gameTime.ElapsedGameTime.TotalSeconds));

These characters move over blocks that are not enabled (which I am hoping turns off collision detection)
block fixture creation-
fixture = FarseerPhysics.Factories.FixtureFactory.CreateRectangle(, Width, Height, 1.0f, new Vector2(X, Y));
fixture.Body.BodyType = BodyType.Static;
fixture.Friction = 0.5f;
fixture.Body.Enabled = false;

I tried setting the friction coefficient to 0.5f on the fixture but that didn't change anything; I also do not believe this would work in the Y plane.  So I tried to create frictionJoints using:
friction = FarseerPhysics.Factories.JointFactory.CreateFixedFrictionJoint(, fixture.Body,Vector2.Zero);

But as soon as I make the joints active no movement occurs.  I assumed the joints would take the fixture friction coefficient and average the two surfaces.
Any documentation on FrictionJoints, or best approaches to this problem would be greatly appreciated.