Page 1 of 1

MotorJoint - missing functions?

Posted: Tue Nov 19, 2024 1:34 am
by Nikki
Hiya,

I'm learning and experimenting with love2d physics library,
Specifically The MotorJoint, in the wiki (https://love2d.org/wiki/MotorJoint) it is summarized like
Controls the relative motion between two Bodies. Position and rotation offsets can be specified, as well as the maximum motor force and torque that will be applied to reach the target offsets.'
But it just offers function to get and set linear and angular offsets, it doesn't offer ways to set the force and torque it can apply to the second body for it to 'control the motion' as far as I can tell.

WhenI look at the box2d docs (https://box2d.org/documentation/group__ ... joint.html) their motorjoint also has:

Code: Select all

void 	b2MotorJoint_SetMaxForce (b2JointId jointId, float maxForce)
 	Set the motor joint maximum force, typically in newtons.
 
float 	b2MotorJoint_GetMaxForce (b2JointId jointId)
 	Get the motor joint maximum force, typically in newtons.
 
void 	b2MotorJoint_SetMaxTorque (b2JointId jointId, float maxTorque)
 	Set the motor joint maximum torque, typically in newton-meters.
 
float 	b2MotorJoint_GetMaxTorque (b2JointId jointId)
 	Get the motor joint maximum torque, typically in newton-meters.
These functions seem missing from love2d MotorJoint or am I missing something else?

Re: MotorJoint - missing functions?

Posted: Tue Nov 19, 2024 1:41 am
by Nikki
edit: ok I was missing some undocumented functions, my intellisense was saying they were wrong but i could after inspect the joint like so

Code: Select all

print(inspect(getmetatable(joint)))

I spotted the functions i was looking for :

Code: Select all

  setCorrectionFactor = <function 20>,
  setMaxForce = <function 22>,
  setMaxTorque = <function 23>,

Re: MotorJoint - missing functions?

Posted: Tue Nov 19, 2024 3:51 am
by slime
love currently uses Box2D 2, which is significantly different in many areas from the freshly released box2D 3 (whose docs are on the linked page), for what it's worth.