This project has moved and is read-only. For the latest updates, please go here.

Problem with Motors in reverse

Topics: User Forum
Jul 27, 2010 at 6:29 PM



I'm using FP 2.1.3 and I'm sure I never had this problem previously.. but I'm using a rectangle body with a circular body attached by revoluteJoint and motors enabled. But now, whenever I apply negative motor_speed to go in reverse, it moves at a constant (yet incredibly slow) speed backwards. No matter what I try and do, it just won't go at the same speed in reverse as it does forward. I've tried all kinds of values for everything I can think of.


All I'm doing at the moment is simple:

            joint.Motor_Speed += acceleration;


and when the user presses left or right, then its either acceleration--; or acceleration++;

When the motor_speed is positive, it zooms forward very fast. But in reverse, it crawls!


I have no idea why. Any suggestions? Still trying to work out how to upgrade to FP3.0 in the mean-time..

Jul 28, 2010 at 6:56 PM
Edited Jul 28, 2010 at 7:21 PM

Still no solution to this. Increasing the torque and motor_speed makes it move faster in reverse, but using the same values, it is still only about 1/5th of the speed that it the motor rotates forward. Does anyone have any code I can look at using Motors that works both forward and backward at the same speeds? Here is my code:


//HERO needs to be rectangle upper body with circle body for feet, attached // revolute joint - motor 

heroUpper = BodyFactory.Instance.CreateRectangleBody(30, 30, 15); 
heroBody = BodyFactory.Instance.CreateCircleBody(mPhysicsSimulator, 70, 30); 
heroUpper.MomentOfInertia = float.PositiveInfinity; heroUpper.Position = position; 
heroBody.Position = position; 
heroGeom = GeomFactory.Instance.CreateCircleGeom(heroBody, 50, 30, new Vector2(0, 0), 0); 
heroGeom.FrictionCoefficient = 95f; 
heroGeom.RestitutionCoefficient = 0; 
heroGeom.CollisionGroup = 7; 
heroGeom.CollidesWith = CollisionCategory.All; 
joint = JointFactory.Instance.CreateRevoluteJoint(mPhysicsSimulator, heroUpper, heroBody, heroBody.Position);
 joint.Motor_Enabled = true; 
joint.Motor_MaxTorque = 180f;
 joint.Motor_Speed = 0; 

// -- HANDLE INPUT -- // 
internal void MoveHero(InputState input, GamePadState gamePadState, KeyboardState keyboardState) 


if (keyboardState.IsKeyDown(Keys.Left)) 


 // -- Make Hero walk left-- // 

joint.Motor_Speed = -90; 


 if (keyboardState.IsKeyDown(Keys.Right)) 


 // -- Make Hero walk right-- //

 joint.Motor_Speed = 30;



I know my body's are off, but no matter what values I use for Motor_speed or MaxTorque, it crawls in reverse compared to forward movement. I've set the left movement as -90, but its still incredibly slow compared to the Motor_Speed = 30; for movement to the right.

Jul 29, 2010 at 12:53 PM

You should also set joint.CollideConnected = false; if the bodies are close to touching. I'm not sure if the JointFactory does that already?

Also, check each frame to see if the Motor_Speed is what it should be.

Thats all I can think of now. RevoluteJoints work perfectly for me, its probably just a little mistake that's hard to find! :)

Jul 29, 2010 at 1:29 PM

I'll give that a try, but they arn't really colliding as they don't wobble or move around. My bodies might be off in terms of the positioning, but they don't collide and fly around or anything so it may already be set to off.

I've printed Motor_speed and maxtorque to the screen, motorspeed is always the correct value its set to when key.Left or key.Right is pressed.

It seems related to Motor_speed though. Because if I set motor_speed to 9000, it will go fast in reverse, but not as fast as 9000 motor_speed forward. It seems like its about 900% slower in reverse.

I've tried it in new projects too, and it does the same. I'm pretty certain that when I first tried revolutejoints, it worked spot on, forward and backwards. So now I really can't see what is different.

I've tried changing the friction, gravity etc, so I think it IS something stupid I can't seem to find. I've figured out how to upgrade to FP3.0 now, so once I've learned how to use that instead, hopefully this won't be a problem.