Problem with making the terrain using several boxes

I am making a side-scrolling motorbike game..
If i create one long platform by creating one long rectangle, my vehicle runs on it smoothly..
However, if I divide the platform into little segments of short rectangles placed side by side, I get problems.

Even if I already layed out all the small rectangles with their Y values all the same, my vehicle / motorbike still acts as if its driving over rocky terrain. Why is this?

Any advice on creating terrain for a side scrolling vehicle game in Box2D?
It has to have hills and jumps as well...
There a tendancy for edges to "nick" or toe-stub other edges, but that should not affect a motorcycle. Could we see some code?
basically, i am positioning boxes of the same width and height in flash and tracing out all their X, Y, and rotation properties..
i then, put all those values inside an array and then generate the Box2D "terrain" from there..
Code:
function setUpBoxes():void
{
   boxValues = [   [28.400000000000002, 386.5, 0],
               [71.4, 386.5, 0],
               [114.4, 386.5, 0],
               [157.4, 386.5, 0],
               [199.9, 386.5, 0],
               [242.9, 386.5, 0],
               [285.90000000000003, 386.5, 0],
               [328.90000000000003, 386.5, 0],
               [371.90000000000003, 386.5, 0],
               [414.40000000000003, 386.5, 0],
               [457.40000000000003, 386.5, 0],
               [500.40000000000003, 386.5, 0],
               [543.4, 386.5, 0],
               [586.4, 386.5, 0],
               [628.9000000000001, 386.5, 0],
               [671.9000000000001, 386.5, 0],
               [714.9000000000001, 386.5, 0],
               [757.9000000000001, 386.5, 0],
               [800.9000000000001, 386.5, 0],
               [843.4000000000001, 386.5, 0],
               [886.4000000000001, 386.5, 0],
               [929.4000000000001, 386.5, 0],
               [972.4000000000001, 386.5, 0],
               [1015.4000000000001, 386.5, 0],
               [1057.9, 386.5, 0],
               [1100.9, 386.5, 0],
               [1143.9, 386.5, 0],
               [1186.9, 386.5, 0],
               [1229.9, 386.5, 0],
               [1272.4, 386.5, 0],
               [1315.4, 386.5, 0],
               [1358.4, 386.5, 0],
               [1401.4, 386.5, 0],
               [1444.4, 386.5, 0],
               [1486.9, 386.5, 0],
               [1529.9, 386.5, 0],
               [1572.9, 386.5, 0],
               [1615.9, 386.5, 0],
               [1658.9, 386.5, 0],
               [1701.4, 386.5, 0],
               [1744.4, 386.5, 0],
               [1787.4, 386.5, 0],
               [1830.4, 386.5, 0],
               [1873.4, 386.5, 0],
               [1915.9, 386.5, 0],
               [1958.9, 386.5, 0],
               [2001.9, 386.5, 0],
               [2044.9, 386.5, 0],
               [2087.9, 386.5, 0],
               [2130.4, 386.5, 0],
               [2173.4, 386.5, 0],
               [2216.4, 386.5, 0],
               [2259.4, 386.5, 0],
               [2302.4, 386.5, 0],
               [2344.9, 386.5, 0],
               [2387.9, 386.5, 0],
               [2430.9, 386.5, 0],
               [2473.9, 386.5, 0],
               [2516.9, 386.5, 0],
               [2559.4, 386.5, 0],
               [2602.4, 386.5, 0],
               [2645.4, 386.5, 0],
               [2688.4, 386.5, 0],
               [2731.4, 386.5, 0],
               [2773.9, 386.5, 0],
               [2816.9, 386.5, 0],
               [2859.9, 386.5, 0],
               [2902.9, 386.5, 0],
               [2945.9, 386.5, 0],
               [2988.4, 386.5, 0],
               [3031.4, 386.5, 0],
               [3074.4, 386.5, 0],
               [3117.4, 386.5, 0],
               [3160.4, 386.5, 0],
               [3202.9, 386.5, 0],
               [3245.9, 386.5, 0],
               [3288.9, 386.5, 0],
               [3331.9, 386.5, 0],
               [3374.9, 386.5, 0],
               [3417.4, 386.5, 0],
               [3460.4, 386.5, 0],
               [3503.4, 386.5, 0],
               [3546.4, 386.5, 0],
               [3589.4, 386.5, 0],
               [3631.9, 386.5, 0],
               [3674.9, 386.5, 0],
               [3717.9, 386.5, 0],
               [3760.9, 386.5, 0],
               [3803.9, 386.5, 0],
               [3846.4, 386.5, 0],
               [3889.4, 386.5, 0],
               [3932.4, 386.5, 0],
               [3975.4, 386.5, 0],
               [4018.4, 386.5, 0],
               [4060.9, 386.5, 0],
               [4103.900000000001, 386.5, 0],
               [4146.900000000001, 386.5, 0],
               [4189.900000000001, 386.5, 0],
               [4232.900000000001, 386.5, 0],
               [4275.400000000001, 386.5, 0],
               [4318.400000000001, 386.5, 0],
               [4361.400000000001, 386.5, 0],
               [4404.400000000001, 386.5, 0],
               [4447.400000000001, 386.5, 0],
               [4489.900000000001, 386.5, 0],
               [4532.900000000001, 386.5, 0],
               [4575.900000000001, 386.5, 0],
               [4618.900000000001, 386.5, 0],
               [4661.900000000001, 386.5, 0],
               [4704.400000000001, 386.5, 0],
               [4747.400000000001, 386.5, 0],
               [4790.400000000001, 386.5, 0],
               [4833.400000000001, 386.5, 0],
               [4876.400000000001, 386.5, 0],
               [4918.900000000001, 386.5, 0],
               [4961.900000000001, 386.5, 0],
               [5004.900000000001, 386.5, 0],
               [5047.900000000001, 386.5, 0],
               [5090.900000000001, 386.5, 0],
               [5133.400000000001, 386.5, 0]   ];
                     
   var terrainBody:b2BodyDef = new b2BodyDef();
   terrainBody.position.Set(0, 0);
   var theTerrain:b2Body = theWorld.CreateBody(terrainBody);
                     
   for (var i:int = 0; i < boxValues.length; i++)
   {
      var boxX:Number = boxValues[i][0];
      var boxY:Number = boxValues[i][1];
      var boxRotation:Number = boxValues[i][2];
            
      // box shape...
      var boxShape:b2PolygonDef = new b2PolygonDef();
      boxShape.SetAsOrientedBox(ptm(22), ptm(7), new b2Vec2(ptm(boxX), ptm(boxY)), boxRotation * Math.PI / 180);
      boxShape.density = 0;
      boxShape.friction = 10;
      boxShape.filter.groupIndex = -2;
            
      theTerrain.CreateShape(boxShape);
   }
         
   theTerrain.SetMassFromShapes();
}


if anyone has a suggestion on a better / more efficient way of creating terrain, please let me know..
i need to get this done ASAP, i will be submitting a prototype by wednesday.. so please.. i need some help...
If you need something to get you started, I have attached a zip file with my svg parser and a sample level from my game. You can get the latest box2dflash from svn and find my polydecompbayazit.as file there. You can visually create a level in inkscape. I'll check up on the forums periodically to answer questions. If you need a mature solution to creating box2d levels, no one has em, but this is what I'm using for my game:

http://tim.kerchmar.com/RopeBurn.html
thanks for the zip file pTymN.. However, I do not have time to learn Inkscape nor study the files inside the zip in depth..
I just need to know (and figure out a solution) as to why my motorbike acts as if its riding on rugged terrain when the boxes that I created for the "terrain" all have the same Y position... they are perfectly flat..

maybe when my bike's wheels hit the corner of the box segment it reacts this way?
what could it be?!?

basically, I just need to be able to create terrain for a side scrolling game using segments of boxes all placed side by side to create a platform...
Are you using circle's for the motorcycle wheels?
i assume you are joking.. hahaha...
yes i am using circles...

the bike has 3 parts.. the "chassis" (the body and the two legs), and the two "wheels"...
each wheel is attached to the chassis via a revolution joint..
to move the bike, i just simply add to the motorSpeed of the joint up until it hits a certain motorSpeed.. to stop it, i just decrease the motorSpeed till its 0..

the vehicle moves smoothly when i use one long box as a platform.. but when i use several little boxes put side by side to form one long platform, the bike moves as if its moving over small rocks; even if i have aleady made sure that all the boxes' Y positions are the same.. its slightly unnoticable when moving at a slow speed.. but as the bike picks up speed, it starts to "jump" / "jitter"..

i am using Box2D v2.02 by the way...

and here is the code for my bike:
Code:
function setUpBike2():void
      {
         var chassisBody:b2BodyDef = new b2BodyDef();
         chassisBody.position.Set(ptm(205), ptm(10));
         
         var boxShape:b2PolygonDef = new b2PolygonDef();
         boxShape.SetAsBox(ptm(36), ptm(7));
         boxShape.density = 1;
         boxShape.filter.groupIndex = -1;
         
         // create main chassis
         chassis = theWorld.CreateBody(chassisBody);
         chassis.CreateShape(boxShape);
         
         // peg 1
         boxShape.SetAsOrientedBox(ptm(15), ptm(3), new b2Vec2(ptm(30), ptm(15)), 60 * Math.PI / 180);
         chassis.CreateShape(boxShape);
         
         // peg 2
         boxShape.SetAsOrientedBox(ptm(15), ptm(3), new b2Vec2(ptm(-30), ptm(15)), 120 * Math.PI / 180);
         chassis.CreateShape(boxShape);
         
         chassis.SetMassFromShapes();
         
         var wheelShape:b2CircleDef = new b2CircleDef();
         wheelShape.radius = ptm(13);
         wheelShape.density = 1;
         wheelShape.friction = 10;
         wheelShape.filter.groupIndex = -1;
         
         var wheelBody:b2BodyDef = new b2BodyDef();
         wheelBody.position.Set(chassis.GetWorldCenter().x + ptm(36), chassis.GetWorldCenter().y + ptm(21));
         wheelBody.allowSleep = false;
         
         // wheel 1
         wheel1 = theWorld.CreateBody(wheelBody);
         wheel1.CreateShape(wheelShape);
         wheel1.SetMassFromShapes();
         
         // wheel 2
         wheelBody.position.Set(chassis.GetWorldCenter().x - ptm(36), chassis.GetWorldCenter().y + ptm(21));
         
         wheel2 = theWorld.CreateBody(wheelBody);
         wheel2.CreateShape(wheelShape);
         wheel2.SetMassFromShapes();
         
         // REVOLUTE JOINT
         var rjd:b2RevoluteJointDef = new b2RevoluteJointDef();
         rjd.motorSpeed = 0;
         rjd.maxMotorTorque = 10;
         rjd.enableMotor = true;
         rjd.Initialize(chassis, wheel1, wheel1.GetWorldCenter());
         
         motor1 = theWorld.CreateJoint(rjd) as b2RevoluteJoint;
         
         rjd.Initialize(chassis, wheel2, wheel2.GetWorldCenter());
         motor2 = theWorld.CreateJoint(rjd) as b2RevoluteJoint;
      }
I have a feeling setting the motorcycle's shapes to be bullets (turning on continuous collision detection) would solve the issue, seeing as how you're encountering it at higher speeds primarily. Failing that, the step iterations may be too low (try 10), the gravity too high, (try new b2Vec2(0,10)).

But given that this bug is one that hasn't been reported to Boris and Erin previously, I'm putting my money on bullet mode.
It could also be your choice of pixel scale. Box2d works better with smaller objects, and can manifest it's displeasure in a number of ways.

PS There's also a lite SVG parser in contrib now, taken from Shaktools implementation. It's com.boristhebrave.Box2DWith.b2Svg. I hope to see someone hooks it up to the decomposition soon.
patadox wrote:
I have a feeling setting the motorcycle's shapes to be bullets (turning on continuous collision detection) would solve the issue, seeing as how you're encountering it at higher speeds primarily. Failing that, the step iterations may be too low (try 10), the gravity too high, (try new b2Vec2(0,10)).

But given that this bug is one that hasn't been reported to Boris and Erin previously, I'm putting my money on bullet mode.


my step iterations is set to 10.. and my gravity also to 10.. still nothing..
i also tried SetBullet(true) on both wheels; as well as the platform, still nothing..
tried setting bullet to true only on the wheels.. and then only on the platform, still nothing...

BorisTheBrave wrote:
It could also be your choice of pixel scale. Box2d works better with smaller objects, and can manifest it's displeasure in a number of ways.


the boxes have a 44 pixel width and a 4 pixel height... i set up the box shape with something like "boxShapeDef.SetAsBox(22 / 30, 4 / 30);"

my problem is kind of similar to this guy: viewtopic.php?f=3&t=1499 except mine is in AS3...

it must be when the wheels hit the corner of the box.. but how can that be? when all the boxes have the same Y value and are perfectly flat???

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