Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent body from rotating in Box2D

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.

like image 498
Undo Avatar asked Jan 26 '13 12:01

Undo


2 Answers

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

like image 93
Pavel Avatar answered Oct 19 '22 02:10

Pavel


In the runtime you want to set set rotationfixed then

b2Body body;  
body->SetFixedRotation(true);
like image 37
Singhak Avatar answered Oct 19 '22 01:10

Singhak