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:
- make mass of bike body , wheel not different. should not big. according box2d manual, stability degrades mass ratio passes 10:1. problem there.
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.
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.
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
Post a Comment