Colliding with the sides of objects

Hi, im new to Box2d and I have been playing with a little prototype I have made.
But the player controlled box is able to "float" when im running against the side of a block. Instead of just allowing gravity to take place like in real life, it seems because I am applying a force horizontally, the friction is too high? Which makes the player vibrate and levitate against the side of an object for a few seconds. Im not sure how to fix this. Im thinking I need to set up my own contact function, which I saw a tutorial for, though im not sure what specifically needs to be done in order for it to be more realistic.
Any one?

Thanks
Hey there,

I had the same issue, however its quite realistic. If you take a piece of paper and push it against a wall, it will stay there as long as you push against the paper.

So you have to check when you apply a force and when you stop applying a force to the player. I solved it buy doing a check on the normals of the player collision.
If the x value of the normal vector is larger than the y, then the player must be pushing against a wall or some other object. Any normal vector angle above roughly 45 degrees will basically not apply a force, so the player cant stick sideways onto walls etc.
I'm not very familiar with Box2D so there may be more elegant solutions.

Code:

// move left
if (!manifold || (-manifold.normal.x < Math.abs(manifold.normal.y))) // check if player not touching left wall (exploit)
            {
               applyMoveImpulse (new V2( -0.1, 0), true, 4, 0.2);
            }
            

...
// move right
if (!manifold || (manifold.normal.x < Math.abs(manifold.normal.y))) // check if player not touching right wall (exploit)
            {
               applyMoveImpulse (new V2( 0.1, 0), true, 4, 0.2);
            }


most game heros have some degree of horizontal control while in the air.

here's what i often do.
-a solution using separate shapes an friction,

i often find it best to have the top and sides of my hero be 0 friction, for various reasons.
so i usually create a rectangle shape for the top portion of my hero 0 friction
and have a circle for the feet (which prevents snags too) and have normal friction on that.
*this circle should be slightly less wide than the rectangle, and usually the top half of the circle will overlap the rectangle.

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