Extracting force data from rigid body joints

If you’ve ever connected two physics objects with a rigid body joint and wished to figure out how much force is applied between them, well, you can!

You have to have created the constrait from within python (the bge.constraints module).
Presumably you’ve set the distance using something like:


joint.setparam(2, distance, distance)

(the 2 is for z translation)

Then you can read that actual distance with:


joint.getparam(2)

The difference between what you set and what you’ve got (after a frame for the new settings to take effect):


distance - joint.getparam(2)

Now, in the short term the constraint acts like a spring, following hookes law: F = -kx
Or if you set the damping on the axis to zero, it always follows hookes law
You can then do some calibration and extract the force!

No idea if that is useful to anyone else.

Dude that is totally awesome! : D I’ve been wondering about this for a while. Thanks a lot for sharing :smiley:

This is exactly what I am looking for, but I am very bad at python…
Can you upload an example .blend to illustrate it?
Thanks a lot for sharing anyway! :slight_smile: