player box sliding

I have been looking at box2d as good choice for my latest project.
However I have run into a bit of a problem.
Now the player is nothing more than a box, and when that box hits a sloped surface, for example another box that is static and doesn't ever move, this is the ground for the level and there are many of these.
I realize that this would be a desirable effect for a normal box, however the player though represented as a box isn't a box at all and I even have it set for fixed rotation.
As such I do not wish for it to be sliding down slopes on its down, but rather when it hits the ground I would wish it for it to stop and not move anymore until I press any keys.
So far sitting the friction very high seems like a hacked solution, although it does prevent the sliding down part.
But this arises another problem, as I have other box's that are present in the level hitting the player and I wish for these to for example push the player around and down slopes, sitting the friction high enough to prevent the sliding also prevents this.
So long question short.
How do I tell the player box to stop on any sloped surface and not to move anymore on its down?
Or maybe a better question would be how do I tell it to not slide down surfaces that have zero density?
Any information at all on this would be must appreciated 🙂
I wouldn't consider high friction a hacked solution. Try walking at some speed, and then stopping. Do you see yourself sliding all over the place? No, because your shoes have a lot of friction with the ground. Similarly, when I push a crate in the real world, there is quite a lot of friction between the ground and it, but I am overcoming that by pushing hard enough.
So it is more a matter of choosing your levels of friction and diving forces carefully.
Yes but in worst case scenario's I would have to set the friction levels to over 100k to stop the sliding.
At that point it seems a bit ridicules does it not?
And yes with what I'm working with that worst case can happen.
Like I said at such ridiculously high friction levels, it really interferes with the physics of so many other things that are going on in the game, including other box's that collide with the player box.
Which is why it I consider it a very hacky solution and doesn't give me the a real solution by any straight of the imagination.
Something's wrong then. Setting, e.g. friction to 1 should mean that a player would slide only at angles greater than 45 degrees. He'd slide a bit if at shallower angles, particularly if falling onto the slope, but would eventually come to rest.
well, fixed rotation here might make the contact area very small and therefore setting "normal" frictions out of place. A box with fixed rotation, horizontally aligned would only have a corner touching a slope, and therefore a very small area for the friction to do its job - wouldn't this be the case? You would have to provide some more info about the world and player shape in order to give this a proper solution. Say that your world only contains of 45degree slopes, if you then had a player being a box, but with 45degrees cuts on the lower left and right corners, you would get greater contact areas. If your world contains a wide variety of slopes, you could do your own "anti-slipping-almost-fixed-rotation" where you turn fixed rotation off and give the character some degrees of freedom so he can tilt left/right and have its flat bottom surface contact the slope. Or perhaps a invisible block on the bottom of the player that adjusts to the ground orientation. I do the tilt in my platformer, tingly or whatever that game is named used a sphere for the player and rotated the sprite to align to the ground i believe
No, surface contact area is not taken into account for friction in Box2Ds simple model. The friction between two shapes is the geometric average of the friction on the two shapes.
Crucially, between shapes of friction 0 and 1E5, the combined friction will be 0. You're not making this mistake are you?
so a box with fixed rotation and only a corner touching a slope would slide just as fast as a box with its whole bottom surface contacting the slope? Or a huge box with the same mass? If this is the case ive just spoken enough crap for the rest of this month. The facade ive built that box2d equals reality is crumbling on me! 😉
It's right there in the manual, zB: http://www.box2d.org/manual.html#d0e815
It doesn't say anything about contact area.
I haven't tested it, but I think all your examples would slide the same.

I don't think anyone promised Box2D == reality 😮 . Exactly where do you find these magical 2d boxes in real life that don't rotate no matter how hard you push them down?
If I remember my physics correctly, friction in reality has surprisingly little to do with contact surface area, unless we're talking about something towards the Velcro end of the spectrum. It's usually just the normal force and the coefficients of friction of the surfaces that determine the friction force.
That's because you've just put an arbitrary co-efficient of friction in there. That co-efficient could change according to all sort of parameters.
But you're right, in normal circumstances I would not expect that co-efficient to depend on contact area. Because otherwise, cutting an object in two would change it's difficulty to push, clearly an absurdity.

Original thread: https://box2d.org/forum/viewtopic.php?t=1756