How to give different friction coefficient to different parts of the body? (Ammo.js)

Hello guys, I want to implement a feature where a body has friction at the bottom and no friction around it in Ammo.js. Is there any way to do that?

I thought I can put a thin fat square around the body to get different friction on different parts of it.

However, I have tried Compound Bodies, but the friction of the imposters are equal and follow the parent imposter friction coefficient.

I also want to use LockJoint to connect the two imposters but the joint only support cannon.js.

I even tried mesh.physicsImpostor.registerBeforePhysicsStep to sync the position and rotation, but the overlap of the imposters make the physical system work improperly.

So can anyone give me a hint on how to make different parts of the body have different friction coefficient?

Yes, this is a quite rare use case :slight_smile:
Did you try to set a joint (like DistanceJoint) with parameters that makes it barely moveable?
I’m not sure this will be enough and you might see some jittering when solver tries to do its best at getting a solution close to ideal. But I would try that anyway.
Maybe with collision callback: try to identify the part of the cube that collides and send force to compensate for difference of roughness.

DistanceJoint seems to be working, thank you very much! I used it to keep the character from sticking to the wall while applying velocity.

1 Like