Open prathamVaidya opened 1 year ago
Yep this seems to be a known issue for cannon.. Even in the jenga example you'll notice that the blocks gradually move. (set solver iterations to 1 to speed this up). You can increase or decrease the time it takes by changing world solver iterations. However even at 50 iterations it still very slightly moves over time. The effect also seems to increase based on the gravity value.
I'd love to see a fix as this is a pretty prevalent issue
https://github.com/schteppe/cannon.js/issues/348 https://github.com/pmndrs/use-cannon/issues/240
Is there an alternative solution to fix this unexpected behaviour?
I read about using sleep or downgrading versions. Did that really work?
@johnnyrainbow
@prathamVaidya sleeping the body seems like the only realistic way to get around it.
Since you still want gravity to apply, what you could do is add a collision listener to the cube. When it collides with another cube, call cubeBody.sleep(). This will stop it from jittering. (Also make sure to use cubeBody.allowSleep = true when you initialise the body)
One solution you could try is the "sleep" feature (see the sleep demo).
In my case, I had to set sleepTimeLimit to 0 and sleepSpeedLimit to 0.1. It worked perfectly.
Check out the Video Proof
When three simple cubes are stacked together vertically, after some time the cube experience a force to the left direction. I checked the plane is not rotated at y or z axis. Am I missing something obvious or its just a bug in CannonJS?