开发者

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?


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);


I'm trying to implement a pong-style game in Processing/Box2d library and I anticipate having the same problem. One thing that comes to mind is to maintain a hidden object in the Box2d world, one that operates with joints the conventional way, and then draw a virtual object that follows the mouse with no frame delay. This might be adequate to fool the user.

On the other hand, Box2d is not a strict physics simulation and allows for some forgiveness in overlapping objects, so it really seems like there should be a way to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜