Hey this is wat i done for the creation of the bodies.
//----carBody
carBodyDef = new b2BodyDef();
carBodyDef.position.Set((hero_mc.x-screen.x) / 30, (hero_mc.y-screen.y) / 30);
carBodyDef.type=b2Body.b2_dynamicBody;
carBodyDef.userData=hero_mc
carBody=world.CreateBody(carBodyDef)
carBox=new b2PolygonShape();
carBox.SetAsBox(carWidth/30,carHeight/30)
carFixtureDef=new b2FixtureDef()
carFixtureDef.shape=carBox;
carFixtureDef.density=0.1;
carFixtureDef.friction=0.5;
carFixtureDef.restitution=0.2;
carFixtureDef.filter.groupIndex=-1;
carBody.CreateFixture(carFixtureDef)
// ************************ LEFT AXLE CONTAINER ************************ //
var leftAxleContainerShape:b2PolygonShape = new b2PolygonShape();
leftAxleContainerShape.SetAsOrientedBox(axleContainerWidth/worldScale,axleContainerHeight/worldScale,new b2Vec2(-axleContainerDistance/worldScale,axleContainerDepth/worldScale),axleAngle*degreesToRadians);
var leftAxleContainerFixture:b2FixtureDef = new b2FixtureDef();
leftAxleContainerFixture.density=0;
leftAxleContainerFixture.friction=0;
leftAxleContainerFixture.restitution=0;
leftAxleContainerFixture.filter.groupIndex=-1;
leftAxleContainerFixture.shape=leftAxleContainerShape;
// ************************ RIGHT AXLE CONTAINER ************************ //
var rightAxleContainerShape:b2PolygonShape = new b2PolygonShape();
rightAxleContainerShape.SetAsOrientedBox(axleContainerWidth/worldScale,axleContainerHeight/worldScale,new b2Vec2(axleContainerDistance/worldScale,axleContainerDepth/worldScale),-axleAngle*degreesToRadians);
var rightAxleContainerFixture:b2FixtureDef = new b2FixtureDef();
rightAxleContainerFixture.density=0;
rightAxleContainerFixture.friction=0;
rightAxleContainerFixture.restitution=0;
rightAxleContainerFixture.filter.groupIndex=-1;
rightAxleContainerFixture.shape=rightAxleContainerShape;
// ************************ MERGING ALL TOGETHER ************************ //
carBody.CreateFixture(leftAxleContainerFixture);
carBody.CreateFixture(rightAxleContainerFixture);
//adding wheels
//-----leftAxle----------
axleShape = new b2PolygonShape();
axleShape.SetAsOrientedBox(3/worldScale, 18/worldScale, new b2Vec2(0,0),3.5);
axle1Def=new b2BodyDef();
axle1Def.userData=leftPiston;
axle1Def.type=b2Body.b2_dynamicBody;
leftAxle=world.CreateBody(axle1Def);
axleFixtureDef=new b2FixtureDef();
axleFixtureDef.shape=axleShape;
axleFixtureDef.density=0.1;
axleFixtureDef.friction=0.5;
axleFixtureDef.restitution=0.2
leftAxle.CreateFixture(axleFixtureDef);
leftAxle.SetPosition(new b2Vec2(carPosX/worldScale-axleContainerDistance/worldScale-axleContainerHeight/worldScale*Math.cos((90-axleAngle)*degreesToRadians),carPosY/worldScale+axleContainerDepth/worldScale+axleContainerHeight/worldScale*Math.sin((90-axleAngle)*degreesToRadians)));
//------righAxle------------
axleShape = new b2PolygonShape();
axleShape.SetAsOrientedBox(3/worldScale, 20/worldScale, new b2Vec2(0,0),5.8);
axle2Def=new b2BodyDef();
axle2Def.userData=rightPiston;
axle2Def.type=b2Body.b2_dynamicBody;
rightAxle=world.CreateBody(axle2Def);
axleFixtureDef=new b2FixtureDef();
axleFixtureDef.shape=axleShape;
axleFixtureDef.density=0.1;
axleFixtureDef.friction=0.5;
axleFixtureDef.restitution=0.2;
rightAxle.CreateFixture(axleFixtureDef);
rightAxle.SetPosition(new b2Vec2(carPosX/worldScale+axleContainerDistance/worldScale+axleContainerHeight/worldScale*Math.cos((90-axleAngle)*degreesToRadians),carPosY/worldScale+axleContainerDepth/worldScale+axleContainerHeight/worldScale*Math.sin((90-axleAngle)*degreesToRadians)));
//-----frontWheel--------
circleShape=new b2CircleShape(wheelRadius/worldScale);
circleShape.SetRadius(0.92)
wheelFixture=new b2FixtureDef()
wheelFixture.shape=circleShape;
wheelFixture.density=1;
wheelFixture.friction=0.9;
wheelFixture.restitution=0.1;
wheelFixture.filter.groupIndex=-1
wheel2Def=new b2BodyDef();
wheel2Def.userData=rightWheel;
wheel2Def.position.Set(7.96,4.3)
wheel2Def.type=b2Body.b2_dynamicBody;
front_wheel=world.CreateBody(wheel2Def)
front_wheel.CreateFixture(wheelFixture)
//-----rearWheel-------------
circleShape=new b2CircleShape(wheelRadius/worldScale);
circleShape.SetRadius(0.87)
wheelFixture=new b2FixtureDef()
wheelFixture.shape=circleShape;
wheelFixture.density=1;
wheelFixture.friction=0.9;
wheelFixture.restitution=0.1;
wheelFixture.filter.groupIndex=-1
wheel1Def=new b2BodyDef();
wheel1Def.userData=leftWheel;
wheel1Def.position.Set(3.92,4.35)
wheel1Def.type=b2Body.b2_dynamicBody;
rear_wheel=world.CreateBody(wheel1Def);
rear_wheel.CreateFixture(wheelFixture)
//-----------------DISTANCE JOINT----------------------------------
var disJointDef:b2DistanceJointDef=new b2DistanceJointDef();
disJointDef.Initialize(front_wheel,rear_wheel,front_wheel.GetWorldCenter(),rear_wheel.GetWorldCenter())
disJoint=world.CreateJoint(disJointDef) as b2DistanceJoint;
// ************************ PRISMATIC JOINTS ************************ //
var leftAxlePrismaticJointDef:b2PrismaticJointDef=new b2PrismaticJointDef();
leftAxlePrismaticJointDef.lowerTranslation=0;
leftAxlePrismaticJointDef.upperTranslation=axleContainerDepth/worldScale;
leftAxlePrismaticJointDef.enableLimit=true;
leftAxlePrismaticJointDef.enableMotor=true;
leftAxlePrismaticJointDef.Initialize(carBody,leftAxle,leftAxle.GetWorldCenter(), new b2Vec2(-Math.cos((90-axleAngle)*degreesToRadians),Math.sin((90-axleAngle)*degreesToRadians)));
leftAxlePrismaticJoint=world.CreateJoint(leftAxlePrismaticJointDef) as b2PrismaticJoint;
leftAxlePrismaticJoint.SetMaxMotorForce(25);
leftAxlePrismaticJoint.SetMotorSpeed(25);
var rightAxlePrismaticJointDef:b2PrismaticJointDef=new b2PrismaticJointDef();
rightAxlePrismaticJointDef.lowerTranslation=0;
rightAxlePrismaticJointDef.upperTranslation=axleContainerDepth/worldScale;
rightAxlePrismaticJointDef.enableLimit=true;
rightAxlePrismaticJointDef.enableMotor=true;
rightAxlePrismaticJointDef.Initialize(carBody,rightAxle,rightAxle.GetWorldCenter(), new b2Vec2(Math.cos((90-axleAngle)*degreesToRadians),Math.sin((90-axleAngle)*degreesToRadians)));
rightAxlePrismaticJoint=world.CreateJoint(rightAxlePrismaticJointDef) as b2PrismaticJoint;
rightAxlePrismaticJoint.SetMaxMotorForce(25);
rightAxlePrismaticJoint.SetMotorSpeed(25);
// ************************ REVOLUTE JOINTS ************************ //
var leftWheelRevoluteJointDef:b2RevoluteJointDef=new b2RevoluteJointDef();
leftWheelRevoluteJointDef.Initialize(rear_wheel,leftAxle,rear_wheel.GetWorldCenter());
leftWheelRevoluteJointDef.enableMotor=true;
leftWheelRevoluteJoint=world.CreateJoint(leftWheelRevoluteJointDef) as b2RevoluteJoint;
leftWheelRevoluteJoint.SetMaxMotorTorque(50);
var rightWheelRevoluteJointDef:b2RevoluteJointDef=new b2RevoluteJointDef();
rightWheelRevoluteJointDef.Initialize(front_wheel,rightAxle,front_wheel.GetWorldCenter());
rightWheelRevoluteJointDef.enableMotor=true;
rightWheelRevoluteJoint=world.CreateJoint(rightWheelRevoluteJointDef) as b2RevoluteJoint;
rightWheelRevoluteJoint.SetMaxMotorTorque(50);
where i'm wrong?? 😢