Rapier set fixed z position for rigid body

Hi.

How can I force in rapier for a rigid body a fixed z postion and still have the same interactions between rigid bodis.

I tried body.setTranslation({ x: currentPosition.x, y: currentPosition.y, z:0.3 }, true); but it messes up the interactionss, it keeps the z postion as I want but the rest of the pshisics is not good.

I also tried this but still not working correctly.

const icosahedronBody = this.world.createRigidBody(
RAPIER.RigidBodyDesc.dynamic()
.setTranslation(transPos, transPos, .3)
.setRotation(rotationQuaternion)
.setCanSleep(false)
);
icosahedronBody.lockTranslations(false, false, true);

Thank you.

rigidbody.enabledTranslations(true, true, false)

In the example below, all objects are locked on the z axis. Click them to make them bounce.

had a demo sitting around using this api as well

https://codesandbox.io/p/sandbox/optimistic-vaughan-8skrmk?file=%2Fsrc%2FApp.js%3A34%2C18

1 Like

Thank you.

iT works but it still the psychic’s dose not look right in my case, I am using a body to push around the other objects when the mouse moves, basically, pushing the objects on the x and y axis with the mouse.

Can you update your example with this functionality I am lost.

Thank you.

This is what I am trying to do but the collision between the ball and the rest of the bodies is not natural is like it is sticky to them.

Any help is appreciated it, is the first time I have used psychics and I am a bit lost.

What I want is the sphere to push more accurately the bodies like a force because I will hide it visually now it kinda gets glued, I am not sure what I am doing wrong

https://webdesign-flash.ro/ht/fwd/

Thank you.

I did it, this is what I wanted actually is better that what I wanted Start

Thank you!