Something obvious is skipping my mind with Bullet Physics library, so apology in advance:

I have a dynamic rigidbody, which I'd like to have its Y (up/down) coordinate to be at constantly at a certain value, let's say 50 units in world space, and move freely along the X Z axis.

With the following code, I set the get the body current origin, and just correct the Y coordinate to 50, like this:

    m_bt_rigid_body->setDamping(0.5f, 0.5f);
    btTransform trans = m_bt_rigid_body->getCenterOfMassTransform();
    btVector3 bodyPos = trans.getOrigin();
    btScalar desiredHeight = 50.0f;

this works but the body is wildly shaking, up and down, see videos:



which is surprising considering the value's constant nature (50.0f). As you can see on the videos, the X Z values are smooth, as they left intact.

The code above is executed in a bullet's pre-tick callback function. I tried the on-tick callback function, but it shakes even more. I also tried to grab the motionstate (default) transformation and set it in rendering frame, but no joy.

I have no other place i manipulate this body. Its mass is 1.0, and the gravity is -9.8, and the body does not collide with anything in the videos.

How could this jittering be eliminated?

(I see in other posts that kinematic objects have no such issues, but my use case is with plain dynamic bodies).


  • 1
    \$\begingroup\$ This thread suggests using prismatic constraints to lock a body into one plane of motion — have you tried something like that? \$\endgroup\$
    – DMGregory
    Jun 24, 2023 at 17:35
  • \$\begingroup\$ @DMGregory thanks. It does not seems to be applicable. My example is simplified as my ultimate goal is that the Y value derives from a ray intersection point, so i am not after locking the body movement to a plane, but to arbitrary intersection points \$\endgroup\$
    – Avi
    Jun 24, 2023 at 18:52
  • \$\begingroup\$ The set of all points whose y coordinate is equal to the y of the ray intersection point forms a plane. In what way would constraining movement to have the same y as the ray intersection differ from constraining movement to the plane with that y value? \$\endgroup\$
    – DMGregory
    Jun 24, 2023 at 19:51

1 Answer 1


The solution was easy. Just call clearForces() after setCenterOfMassTransform(), so the remainder forces don't mess with the body transformation.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .