Newbie help with motors

Hello all,

Sorry to bother you with this one, but I was wondering if someone could spare the time to explain motors to a newbie like me who has very little physics knowledge 🙂

I'm currently trying to just work out what each of the properties of the motor actually does, but the documentation mainly just uses the name in a sentence and I can't seem to find any explained 'examples' of code (Google has failed me yet again *sigh* lol)

I am using the following code to rotate a triangular object about its centre:

var jointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
//Attach the triangle to the background
jointDef.Initialize(gameWorld.GetGroundBody(), rotatingTriangle, rotatingTriangle.GetWorldCenter());
jointDef.maxMotorTorque = 5;
jointDef.motorSpeed = 1.5;
jointDef.enableMotor = true;
var jointInWorld:b2RevoluteJoint = gameWorld.CreateJoint(jointDef) as b2RevoluteJoint;

I had initially thought that maxMotorTorque would restrict the speed at with the object could 'spin' (torque is something to do with spinning right? :/ ) but this doesn't seem to be the case and the object keeps gradually getting faster after a very slow start. What I'd really like is for the object to spin at a set pace regardless of other objects bouncing off it (it seems to slow down/speed up when hit from different angles) and only rotate at a set speed, not continually speed up. What is the best way to do this? I've been digging about for days trying to get an explanation of this stuff that I can understand haha I'm really regretting not taking Physics at school now 😕
i'm guessing your torqe is too low. If you want a constant rotating speed, minimize the mass of your triangle as much as possible. Then bump up the torque to something like 100 to start with, lower/increase until your at the point where it just manages to keep its speed.

Basically, torque is the power of the motor. The more power it has, the quicker it can get the motor to its desired speed, and the quicker the motor can get it back up to that speed when a object hits it.
Perfect, that's exactly what I was needing! Thanks for explaining things too, I understand what's going on much better now. 😀 Hopefully this will be the last of my 'newbie' posts and I should be able to start helping out other folks soon haha

Original thread: https://box2d.org/forum/viewtopic.php?t=4899