Revolute joint and Prismatic Joint

No, the prismatic should not make any difference.

So, you can make the bike go slower and faster, but there is a maximum limit to the top speed? Are you using pixels as units to define the size of the bike? Box2D is intended to use units of meters, so you should choose measurements that are closer to real-world sizes, eg. diameter of wheel is about 1 unit etc.

See the first question on this page, maybe it's relevant: http://www.iforce2d.net/b2dtut/gotchas
hi

if i change the world.step like this
world.Step(1/18,30,30);

bike speed is fast. Is the way correct?
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?? 😢
Hmm.... maybe you are hitting the limit of how far a body can rotate in one time step. Your motor speed is set to 25*pi, and the time step length is 1/30 so each time step the wheel would have to turn 25/30*pi = 0.83 * pi

The default limit for rotation per time step is set in b2Settings as:

#define b2_maxRotation (0.5f * b2_pi)

You could try making your time step shorter, eg. 1/60 seconds, but even then the angle per time step would be about 0.42 so you would still be very close to the limit.

Your rear wheel radius is 0.87 which is about twice as big as real life so if you are using real world meters for units, maybe this is the diameter instead of the radius?

btw, since one revolution is 2*pi radians your desired speed of 25*pi radians per second is about 12.5 revolutions per second, with a wheel radius of 0.87 is about 68m/s or 245km/h. This is still realistic but I have to wonder if it's is the kind of speed you are aiming for in this case... I have ridden bikes that fast before but they sure weren't dirt bikes 😀
See this link.

http://youtu.be/gVgxL76hHiQ

This is the speed i'm getting. And the bike engine is touching on the floor if i ride it slowly.

Original thread: https://box2d.org/forum/viewtopic.php?t=7909