Ammo joint connected axis change

Hi All,

Using cannon physics it is possible to change the connected axis vector after the joint is created. I cant figure out how to achieve same behavior with Ammo.
Here is an example where after hitting a button the angle is changed.

I think native ammo doesnt allow changing this axis at least I cant figure it out.
I tried to achieve same functionality with parenting axle box to some chassis box and then rotating axle but I think constrain joints dont like meshes with imposters parenting.

Finally figured it out. I changed the sphere pivot matrix and it works!

Just for completeness another playground. First button keeps adding to relative rotation. Other two are setting absolute rotation of the wheel.

It works for cannon, ammo and oimo physics pluggins.

1 Like

Ok, I checked it on the ground and it seems pivot matrix only affects the mesh but not the impostor. So back to the drawing board.

I added logging for the imposter and it does seem to be rotated.

Unfortunately when I use it as a steering in a rigid body vehicle it appears like it isnt rotated.

@Cedric Any ideas anyone?

The rotation was from the motor. When the motor is off you can see the impostor is not rotated.

@Cedric is definitely the right person to ping here :slight_smile:

Setting pivot matrix will only change the way the mesh’s origin is interpreted.
For a wheel, I would use Hinge and Hinge2 like in this example:

Difference between physics engine is noticeable for simple rigid bodies but even more with Joints. Tweaking with 1 physics engine might not give good results with another. I would suggest to focus on 1 physics engine.


Thanks @Cedric ! This approach should work for ammo as well with some tweaking.

1 Like

Hello @kri100s just checking in, was your question answered? :slight_smile:

hi @carolhmj , yes it was. Marked as the solution now.

1 Like