11

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.

Mel
  • 5,837
  • 10
  • 37
  • 42
Rob
  • 7,039
  • 4
  • 44
  • 75

1 Answers1

14

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

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

Martin
  • 39,569
  • 20
  • 99
  • 130
  • looks like what I need. What is a sensible value for this? Initially I'd assume setting it to 0.f will ensure it never gets stuck, but can this have adverse effects? – Rob Mar 21 '11 at 18:41
  • Start at zero and work up - 0.1 should be fine. 0 would only have bad effects if you were looking to have objects come to rest against a surface - they would constantly jiggle. – Martin Mar 21 '11 at 19:05
  • 1
    Is there any way to modify that value without hacking the define in the source code? Bad design. – Ciro Santilli OurBigBook.com Dec 07 '17 at 08:18