Friction Coefficient

Mar 29, 2010 at 9:06 PM


Hello, as everyone else, Im trying to make a plaformer, and Ive been reading the forums and our physics are aceptable now, although, as many users, Im having issues with pronounced slopes, Ive read that for avoiding that you should increase the frictionCoefficient, but Ive been trying with all possible values, and I cant make it stop. I modified a simple demo to show my problem


Here is a sample sourcecode of my problem(using the demo samples)


in that sample, I have a ball, that I move by using

_circleBody.ApplyImpulse(new Vector2(torque * 10, 0));

And before that, I use


_circleBody.ApplyImpulse(new Vector2(_circleBody.LinearVelocity.X * -_circleBody.Mass, 0));

so it only moves when you press left or right, but it doesnt matter what values I use for friction, (Im using float.MaxValue), it makes no difference, when I
wanna move the ball, maybe I should use something else besides friction, but I dont know what else, what I want is that the friction is high enough, the ball wont 
move at all.


You can see our current prototype at

around 1:08, you can see that the player moves down because of the slope, I would like to make it stand there without moving down, Ive been playing with friction and gravity(and although disabling gravity works, its too much trouble for when to activate or deactivate it), and since I wanna add more stuff, it could get even more tricky to be removing and adding gravity, so please, any suggestion or help would be good, thanks



Mar 30, 2010 at 2:02 AM

Here is what I came up with.


You will still have to fiddle with your angle finding so the player can't climb on walls, but this seems to do what you described.

Mar 31, 2010 at 12:04 AM

Thank you so much, it indeed does what I want to, although I still would like to know how friction works, but this is the exact solution to my issues, thank you very much

Mar 31, 2010 at 12:24 AM

In 2.x engine friction is an estimate. It basically just scales the force vector by the inverse of the friction, perpendicular to the contact normal. That's just off the top of my head though. I'll do a little more research for you in the next few days. I've been so busy in the 3.x engine I can't remember exactly how the 2.x engine does it.