当 2 个物体在旋转时发生碰撞时 Box2d 的奇怪行为

Box2d strange behavior when 2 bodies colliding while rotating

最近在开发一款游戏(应该是space类似重装的舰船游戏)。 所以我的情况: - 我得到了 2 个身体,0 恢复和 0 摩擦 - 当它们碰撞时,由于我的线性倾倒,它们会滑动并失去速度 - 但是当它们中的一个都在旋转时(使用 setangularvelocity),它们会以非常高的速度反弹,我不明白为什么它们反弹得这么厉害。

(我读到即使没有恢复原状也应该有一点弹跳,但我不期待这样的事情)

这是一些代码:

    b2PolygonShape shape;

    b2BodyDef def;
    def.type = b2_dynamicBody;

    b2FixtureDef fix;
    fix.density = 1.f;
    fix.restitution = .0f;
    fix.friction = 0.f;


    bbody = world->CreateBody(&def);
    bbody2 = world->CreateBody(&def);


    bbody->SetLinearDamping(2.0f);
    bbody2->SetLinearDamping(2.0f);

    // PIXELPERMETER is the scaling from pixels to meter. (30)
    shape.SetAsBox(32 / PIXELPERMETER/*=30*/, 32 / PIXELPERMETER);

    fix.shape = &shape;
    bbody->CreateFixture(&fix);
    bbody2->CreateFixture(&fix);

    bbody2->SetTransform(b2Vec2(-100 / PIXELPERMETER, 0), 0);

也许你应该尝试调整你身体的质量数据?

b2MassData massData; massData.mass = 50; //Just tweak me massData.I = 1; //Just never set me to 0 if you don't want to have nAn propagating massData.center = b2Vec2_zero; bbody->SetMassData(&massData);