Prevent body from rotating in Box2D

Undo picture Undo · Jan 26, 2013 · Viewed 9.3k times · Source

I am currently using Box2d, more precisely the Java port jBox2d.

I have a circle that is colliding with other circles when falling (all those circles form a kind of a crank, see picture below).

illustration

Naturely, the circle begins to rotate when falling. But I would like to prevent it from rotating so that the friction is much higher.

Answer

Pavel picture Pavel · Jan 26, 2013

To prevent body from rotating set fixedRotation = true at BodyDef or call setFixedRotation of Body (if you need run-time change behavior).