setSleepingThresholds not working

Digging through bullet’s documentation, it seems that setSleepingThresholds works together with setDeactivationTime. As setDeactivationTime is missing in ammo.js, that may be the reason why setSleepingThresholds isn’t working. I’m really not sure about this as a default deactivation time may have been set internally by ammo.

I’ve tried using physicsBody.getWorldTransform().getOrigin() to save the position of the physics body, and setting it back if velocity is below a certain threshold. Not perfect, but seems to work well enough https://playground.babylonjs.com/#IMD13Q#5

The body still wiggle around a bit, but it’s no longer cumulative due to the position reset. It occasionally wiggles too much, exceeds the threshold, and move out of position, but that can be alleviated by raising the threshold (…at the expense of affecting low speed movement).

If anyone can suggest a better approach, it’ll be greatly appreciated.

2 Likes