Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Box2d: mousejoint without inertial delay

I'm using mousejoint to drag bodies in box2d, but it causes inertial delay.

Does it exist any way to drag a body instantaneously?

like image 600
Ricibald Avatar asked Dec 17 '09 15:12

Ricibald


1 Answers

The solution is to tune up properties frequencyHz and dampingRatio in your b2MouseJointDef.

For example:

b2MouseJointDef md;
md.body1 = _groundBody;
md.body2 = body;
md.target = p;
md.maxForce = 10000.0f * body->GetMass();
md.dampingRatio = 0;
md.frequencyHz = 100;
_world->CreateJoint(&md);
like image 163
Ricibald Avatar answered Sep 21 '22 01:09

Ricibald