0
votes

I am developing a game recently (it's should be a space ship game like reassembly). So my situation: - i got 2 bodies with 0 restitution and 0 friction - when they are colliding they slide and lose velocity because of my lineardumping - but when 1 of them both is rotating (with setangularvelocity), they bounce off with a very high velocity and i can't figure out why they even bounce this hard.

( and i read that there should just be a little bouncing even if there is no restitution, but i am not expecting something like this)

here's some code:

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

1 Answers

0
votes

Maybe you should try to tweak the mass data of your bodies ?

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