1

I am using box2d line joint, to simulate wheel with suspension, but I can not manage to accelerate properly.

My joint code:

            LineJointDef fJointDef = new LineJointDef();
        fJointDef.initialize(mainBody, wheelBody, wheelBody.getWorldCenter(), new Vector2(0,-1));
        fJointDef.enableMotor = true;
        fJointDef.upperTranslation = 0.10f;
        fJointDef.lowerTranslation = -0.10f;
        fJointDef.enableLimit = true;
        fJointDef.motorSpeed = 10;
        fJointDef.maxMotorForce = 30f;

Suspension works, wheel is properly attached to the vehicles body, it might move etc, now I do not really know how to move it properly, editing motor speed and max motor force of the line joint does nothing. I ended up, to applying angular impulse to the wheel body:

wheelBody.applyAngularImpulse(5 * direction);

But with this, vehicle might move with infinity speed, would be grateful if someone can provide some help, thanks.

4

0 回答 0