Hi, how would I go about creating a motor in matter js?
I've created a box with legs:

I'd like to rotate the constraint like a motor but I'm not sure how to do that.
I tried just outright rotating the whole leg but that seemed to create unrealistic results.
FYI I'm planning to use this for creating an AI similar to https://www.youtube.com/watch?v=K-wIZuAA3EY
Uh, guys?
If there's something missing from my question let me know and I'll be happy to include it.
There is no code in your question so it is hard for people to know what you're referring to when you say "the constraint". And it's not clear what you mean by "like a motor" - what characteristics of a motor are you trying to emulate? Are you trying to create a rotating joint (that is, a constraint with length 0) and force the bodies it is attached to to rotate at a constant speed relative to each other? Or apply a constant torque? Or have them return to a certain angle in the absence of other forces on them? What (specifically, with reference to your code) have you tried and why did the results seem unrealistic to you?
Hi Richard, thanks for your feedback I'll try and make the question clearer.
So say I have two rectangles connected by an axle like this:

I can do this very easily with Matter js by making a zero length constraint.
But my problem is that I want to turn the axle left so that the two rectangles would look like this:

And as far as I know I can't do that with a constraint.
In summary I'm looking for something like a zero length constraint, but I can say "hey turn left at this speed" and this new axle will start rotating the two rectangles.
Do you mean turn one body about the axle point? You can try using Body.applyForce first to do that, there are a few other ways though, see the body manipulation example.
But from the looks of what you're trying to achieve, most likely a more stable approach is to apply another constraint between the bodies and control its length as if it were a hydraulic piston, if that makes sense.
Hmm yeah creating a 2nd constraint that works like a pistol that makes more sense, thanks I'll try and do that.