Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown Force is applied on some vertically stacked cubes on straight plane? #177

Open
prathamVaidya opened this issue Mar 6, 2023 · 4 comments

Comments

@prathamVaidya
Copy link

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?

@johnnyrainbow
Copy link

johnnyrainbow commented Jan 8, 2024

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

schteppe#348
pmndrs/use-cannon#240

@prathamVaidya
Copy link
Author

Is there an alternative solution to fix this unexpected behaviour?

I read about using sleep or downgrading versions. Did that really work?

@johnnyrainbow

@johnnyrainbow
Copy link

johnnyrainbow commented Jan 9, 2024

@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)

@gabrieldejesus
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants