java - AndEngine Box2d - how to aviod joint "streching"? -


i'm making game, go on bike through hills. have problem creating joints between bike's frame , it's wheels - joints stretch somehow, not firm.

here image: joints issue http://kpachul.linuxpl.info/files/bike_joints_issue.png

i've tried different joints different setup, happened. want no amortization, firm joints between bike , it's wheels.

this setup, use now:

    mframe = new frame(px, py, pphysicsworld);     mwheelfront = new wheel(px + 47.0f, py - 28.0f, pphysicsworld);     mwheelrear = new wheel(px - 53.0f, py - 28.0f, pphysicsworld);      this.attachchild(mwheelfront);     this.attachchild(mwheelrear);     this.attachchild(mframe);      final revolutejointdef revolutejointdeffront = new revolutejointdef();     revolutejointdeffront.initialize(this.mframe.getbody(), this.mwheelfront.getbody(), this.mwheelfront.getbody().getworldcenter());     revolutejointdeffront.collideconnected = false;     revolutejointdeffront.maxmotortorque = 100f;     pphysicsworld.createjoint(revolutejointdeffront);      final revolutejointdef revolutejointdefrear = new revolutejointdef();     revolutejointdefrear.initialize(this.mframe.getbody(), this.mwheelrear.getbody(), this.mwheelrear.getbody().getworldcenter());     revolutejointdefrear.collideconnected = false;     revolutejointdefrear.maxmotortorque = 100f;     pphysicsworld.createjoint(revolutejointdefrear); 

what do wrong? how "firm" joints?

possibly solutions:

  1. make mass of bike body , wheel not different. should not big. according box2d manual, stability degrades mass ratio passes 10:1. problem there.
  2. scale world, make size of moving bodies between 0.1 , 10 meters. box2d manual says:

    continuous collision not handle joints. may see joint stretching on fast moving objects.

    if using bad scaling, velocity maybe high.

  3. increase count of position , velocity iterations. box2d manual says:

    the suggested iteration count box2d 8 velocity , 3 position. can tune number liking, keep in mind has trade-off between speed , accuracy.

  4. make smaller time step (and increasing fps, keep physic speed normal). experience, time step 1/60 sec good, 1/30 not good, still working, 1/20 quite unstable, , can simulate simple models.

p.s. ground body not optimal :) there can smaller count of fixtures. specially important, if programming mobile platforms.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -