Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
You have to mention that you want the collision to occur or not within triangle bodies you have shown. –  Siddharth Jun 19 '12 at 10:10
    
@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 –  Nikhil Lamba Jun 20 '12 at 6:04

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
+1 for this and thanx for ur answer :) @ Daniel Carlsson –  Nikhil Lamba Jun 20 '12 at 12:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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