1
\$\begingroup\$

I am making a Game from andengine + box2d in Which i am using RevoluteJoint in that case i am facing some problem that when physics body or Sprite Collide with this Revolute joint body then Revolute body stop rotating then after some time it start rotating I am using below code for this :

     this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(movingFace, movingBody, true, true));


         final RevoluteJointDef revoluteJointDef = new RevoluteJointDef();
         revoluteJointDef.initialize(anchorBody, movingBody, anchorBody.getWorldCenter());
         revoluteJointDef.enableMotor = true;
         revoluteJointDef.motorSpeed = 100;
         revoluteJointDef.maxMotorTorque = 200;


         this.mPhysicsWorld.createJoint(revoluteJointDef);

EDIT Here is a screenshot:

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ You have to mention that you want the collision to occur or not within triangle bodies you have shown. \$\endgroup\$
    – Siddharth
    Jun 19 '12 at 10:10
  • \$\begingroup\$ @Siddharth : yes i want collision to occur with triangle bodies but in that case when some other body collide with triangle body then its stop rotating but i want motor never stop if other body collide with triangle body then that body have some reaction \$\endgroup\$ Jun 20 '12 at 6:04
3
\$\begingroup\$

What is happening is that when the triangle hits an object the torque required for the motor to continue exceeds the maxMotorTorque you have set, this effectively stops the motor dead for a while.

The solution is to increase maxMotorTorque high enough so that the motor continues even on collision for your specific game.

Quote from Box2D manual about the joint motor:

A joint motor allows you to specify the joint speed (the time derivative of the angle). The speed can be negative or positive. A motor can have infinite force, but this is usually not desirable. Recall the eternal question:

"What happens when an irresistible force meets an immovable object?"

I can tell you it's not pretty. So you can provide a maximum torque for the joint motor. The joint motor will maintain the specified speed unless the required torque exceeds the specified maximum. When the maximum torque is exceeded, the joint will slow down and can even reverse.

\$\endgroup\$
1
  • \$\begingroup\$ +1 for this and thanx for ur answer :) @ Daniel Carlsson \$\endgroup\$ Jun 20 '12 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.