Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

i have two object like this :

b2WeldJointDef weldJoint; //frist body bodyDefXich.type = b2_dynamicBody; bodyDefXich.position.Set(3, 2);

b2FixtureDef fixtureDef;

b2PolygonShape polygonShape;
polygonShape.SetAsBox(2 ,2 );
fixtureDef.shape = &polygonShape;
//    fixtureDef.density = 0.1;
bodyXich = world->CreateBody( &bodyDefXich);
bodyXich->CreateFixture( &fixtureDef );

//body 2
bodyDefXich1.type = b2_dynamicBody;
bodyDefXich1.position.Set( 9,2);

b2FixtureDef fixtureDef1;
b2PolygonShape polygonShape1;
polygonShape1.SetAsBox(2,2);
fixtureDef1.shape = &polygonShape1;
bodyXich2 = world->CreateBody( &bodyDefXich1);
bodyXich2->CreateFixture( &fixtureDef1 );

weldJoint.Initialize(bodyXich, bodyXich2, bodyXich->GetWorldCenter());
weldJoint.localAnchorA.Set(0, 0);
weldJoint.localAnchorB.Set(0, 0);


world->CreateJoint(&weldJoint);

i joint them with weld joint.

i set : bodyXich->ApplyForce(b2Vec2(500, 0), bodyDefXich.position);

but just only body move. (with weld joint i want two body move when i applyForce into a body).

Thank u very much !!!

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.