Rotating a wheel with a motor

Feb 6, 2012 at 9:34 PM
Edited Feb 6, 2012 at 9:38 PM

 Hello, I am trying to create a moving character based off the rectangle attached to a circle concept. Visually it looks correct, but when I increase the motor speed, the character doesn't move. Here is my code.

this.width = ConvertUnits.ToSimUnits(width);        

this.height =ConvertUnits.ToSimUnits(height);                                     

float upperBodyHeight = this.height - (this.width / 2);           

Vector2 temp = position + Vector2.UnitY * (this.width / 4);           

RectShape = BodyFactory.CreateBody(world,ConvertUnits.ToSimUnits(temp) );           

RectShape.BodyType = BodyType.Dynamic;

  Vector2 temp2= ConvertUnits.ToDisplayUnits(RectShape.Position) - Vector2.UnitY * (upperBodyHeight / 2);            BodyWheel = BodyFactory.CreateBody(world,ConvertUnits.ToSimUnits(temp2));           

BodyWheel.BodyType = BodyType.Dynamic;
 BodyWheel.FixedRotation = false;           

RectShape.FixedRotation = true;                

fixture = FixtureFactory.AttachRectangle(this.width, upperBodyHeight, mass / 2.0f, new Vector2(0,-.25f), RectShape);
 RectShape.Inertia = 1f;           

BodyWheel.Inertia = 1f;           

wheelFixture = FixtureFactory.AttachCircle(this.width / 2, mass / 2.0f, BodyWheel);

  motor = JointFactory.CreateRevoluteJoint(world, BodyWheel, RectShape, Vector2.Zero);               motor.MotorEnabled = true;           

motor.MaxMotorTorque = 1500f;             

motor.MotorSpeed = 0;                       

wheelFixture.IgnoreCollisionWith(fixture);         

  fixture.IgnoreCollisionWith(wheelFixture);           

wheelFixture.Friction = float.MaxValue;

 

I tried to insert as a code comment, but it won't work for some reason.

Any Ideas? Also, if I reverse the order of the bodies in CreateRevoluteJoint, it doesn't move at all, but in it's current state it wiggles a little. If I set RectShape.FixedRotation = false, then the character rectangle rotates around the joint, which is in the middle of the wheel.