Circle shape Friction [as3]

Howdy.
Im a new box2d user. And also a relatively new user of as3 (so far i just finished a game with a lot of complicated code like newbs).
But i have a question though.
Knowing that i use box2d 2.02:
How do i add friction to a circle shape since i understood for what i read that circle isnt affected by friction? so far my code for circle body and shape looks like this:

Code: Select all


                        var ballSprite:Sprite=new Ball();
         parent.addChild(ballSprite);
         
         var ballShapeDef:b2CircleDef=new b2CircleDef();
         ballShapeDef.radius=45/(2 * Vals.RATIO);
         ballShapeDef.density=1.0;
         ballShapeDef.friction=0.9;
         ballShapeDef.restitution=0.3;
         
         var ballBodyDef:b2BodyDef=new b2BodyDef();
         ballBodyDef.position.Set(location.x/Vals.RATIO, location.y/Vals.RATIO);
         
         var ballBody:b2Body;
         ballBody=Vals.world.CreateBody(ballBodyDef);
         ballBody.CreateShape(ballShapeDef);
         ballBody.SetMassFromShapes();
         ballBody.m_angularDamping=0.01;
         
         var velocityVector:b2Vec2=new b2Vec2(initVel.x/Vals.RATIO, initVel.y/Vals.RATIO);
         ballBody.SetLinearVelocity(velocityVector);
         
         super(ballBody, ballSprite);



I mean my ball falls to the ground but it just goes on and rotate till it hits another body and then because of angular damping it ll slow a bit but still if it has the slightest movement going, it will continue to move.


Thanks for having the patience to read such insolent question. 😀
hmm i think i found the answer. I actually gota go and make it a polygon with around 14-16 vertices. Hmm and to find out the vertices location on X and Y axis i gota put the pen on the paper... 🙁
I think you are talking about rolling resistance rather than friction. Since rigid bodies are perfectly rigid they don't have any natural rolling resistance, so they will roll even on a tiny slope. You would need to use angular damping, but that value seems very low - did you try higher values?
sorry for my late reply good sir but i was studying box2d these days.
Tried before to increase the angular damping but with no effect the ball would only have stoped after hiting another object IF its speed was already low, so i created a polygondef with 36 vertices that copies an almost perfect circle.
It probably stops from angular damping though and not friction, not sure.
I see. Making the ball with many sides will work but it's not very efficient if you have many balls like that.
You could mimic rolling resistance by applying a small linear force in the opposite direction to the current velocity of the ball.
I am yet to find out how to apply force or an impulse to a body.
Could you post an exemple?
It's been a while but fwiw: Friction works on circles, it's just that it won't take effect since a circle will choose to roll rather than slide. If it's not important to you that the circle rolls, you can call body.setFixedRotation(true) to stop it from rolling and it will start sliding.

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