English 中文(简体)
How can I prevent a ball from sticking to walls in Box2D?
原标题:

I m experimenting with box2d. I seem to have a problem people describe as sticky walls

I have a ball and a paddle

I m using all the basic recommended scales I could find, 10m world, 1m ball

The ball has the following properties:

shape: circle (.5f radius)
size: 1.0f
density: 1.0f
restitution: 1.0f
friction: 0.0f

The paddle used to move the ball is 1.5m, it has the following properties: shape:

circle (.75f radius)
size: 1.5f
density: 10.0f
restitution: 0.1f
friction: 0.0f

As you see the friction is 0 for all objects.

The ball constantly gets stuck rolling along a wall or completely jammed in the 90 degree corners

I was thinking I could detect a collision with a wall and trigger an applyLinearImpulse to move the ball off the wall.

最佳回答

You need to reduce the minimum velocity threshold for elastic collisions.

Do this by reducing b2Settings::b2_velocityThreshold closer to 0.

问题回答

暂无回答




相关问题
Breaking a concave polygon into convex ones

I m using a game physics library (Box2D) which only supports convex polygon shapes. However, I d like the level builder to be able to just specify concave polygons without having to worry about that. ...

How to set the position of a sprite within a box2d body?

Basically I have 2 polygons for my body. When I add a sprite for userData, the position of the texture isn t where I want it to be. What I want to do is adjust the position of the texture within the ...

Farseer or Box2D? Top-down shooter physics implementation

Which one of these would fit a top down shooter better? I ve heard that Box2D performs faster, but I ve also noticed that it lacks wider community support for XNA (it rather seems to be used for ...

Box2D in Flash runs quicker when drawing debug data than not

I ve created a small game with Box2d for AS3 - I have sprites attached to the stage that take their position from the underlying Box2d world. These sprites are mostly PNGs. When the game runs with ...

GetBodyCount() always returning 0 in Box2d?

I am using the cocos2d-iphone + Box2d engine, I have a simple call in Box2d to create a body: b2Body *crateBody = world->CreateBody(&crateBodyDef); Then I am printing the newly incremented ...

box2d: bigger clickable/touchable area

I m using Box2D on my iPhone app using Cocos2D. I m using mouse joint to drag objects by touch. The touch event is handled to find the corresponding Box2D body using AABB queries. I would want to ...

Falling object in Box2D should rotate due to centre of mass?

I m trying to simulate a falling balloon in Box2DAS3. What is important is that balloon falls the such that the bottom part were you blow it up rotates towards the bottom if it s knock sideways or is ...

热门标签