Ammo rigidbody picker

Hi,

I’m trying to make a mouse picker for my scene called Ammo_Ragdoll. You can find it in the project here:
https://playcanvas.com/project/998667

My code is in scripts/ammo/ammoJointPicker.js

What I thought would work was:

var pickPos = rayCallback.get_m_hitPointWorld();
var localPivot = body.getCenterOfMassTransform().inverse().op_mul(pickPos);
var p2p = new Ammo.btPoint2PointConstraint(body,localPivot);
this.dynamicsWorld.addConstraint(p2p);

Bot the pivot position on the joint is incorrect, im sure the error is in this code because if I set localPivot to 0,0,0 it seems to work fine.

Hope someone can point me in the right direction!

Best,

Erik

Will has a few projects using constraints that could help you?

https://playcanvas.com/project/618829/overview/physics-constraints
https://playcanvas.com/project/431888/overview/ragdoll

I’ve also been playing around with ragdolls here:

Kapture 2022-10-13 at 17.36.42

Might be worth checking the values of localPivot in the console to cross check?

Yeah i have logged things extensively, but the offset between the hit point and the center of the rig is incorrect. The localPivot needs to be in local space of the body. This code is also on the official bullet demo.

See also: