Hello all, I'm currently in the process of trying to get my head around 'joints' and 'motors' as used in Box2D... and not getting very far haha I really need more examples!
I'm just trying to get the triangle called 'rotatingTriangle' to rotate constantly about it's centre of mass as if it was pinned to the background and being driven by a little motor... but it's not moving at all. I think I have attached it to the 'world object' but I'm not sure about this either so I could be wrong. I realise the lower angle and upper angle lines of code are probably unnecessary but I've just copied and pasted from the Manual (because I don't know what anything does) and was planning on tweaking/removing lines of code to get the effect I was wanting.
var jointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
jointDef.Initialize(gameWorld.GetBodyList(), rotatingTriangle, rotatingTriangle.GetWorldCenter());
jointDef.lowerAngle = -0.5 * b2Settings.b2_pi; // -90 degrees
jointDef.upperAngle = 0.25 * b2Settings.b2_pi; // 45 degrees
jointDef.enableLimit = true;
jointDef.maxMotorTorque = 10.0;
jointDef.motorSpeed = 1.0;
jointDef.enableMotor = true;
One other thing that could be causing a problem is that the 'rotatingTriangle' is a static object (e.g. 0 mass), but if I make it non-static the triangle just falls down (but doesn't tip over... it stands up on it's point).
Any help here would be much appreciated, I've been looking in the documentation/manual/etc but I can't make head nor tail of how to correctly set up joints, etc...
I'm just trying to get the triangle called 'rotatingTriangle' to rotate constantly about it's centre of mass as if it was pinned to the background and being driven by a little motor... but it's not moving at all. I think I have attached it to the 'world object' but I'm not sure about this either so I could be wrong. I realise the lower angle and upper angle lines of code are probably unnecessary but I've just copied and pasted from the Manual (because I don't know what anything does) and was planning on tweaking/removing lines of code to get the effect I was wanting.
var jointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
jointDef.Initialize(gameWorld.GetBodyList(), rotatingTriangle, rotatingTriangle.GetWorldCenter());
jointDef.lowerAngle = -0.5 * b2Settings.b2_pi; // -90 degrees
jointDef.upperAngle = 0.25 * b2Settings.b2_pi; // 45 degrees
jointDef.enableLimit = true;
jointDef.maxMotorTorque = 10.0;
jointDef.motorSpeed = 1.0;
jointDef.enableMotor = true;
One other thing that could be causing a problem is that the 'rotatingTriangle' is a static object (e.g. 0 mass), but if I make it non-static the triangle just falls down (but doesn't tip over... it stands up on it's point).
Any help here would be much appreciated, I've been looking in the documentation/manual/etc but I can't make head nor tail of how to correctly set up joints, etc...