How can I stop the cube from shaking
Adding @Cedric but I can’t see the cube shake in your demo (?)
there is jumping
I can’t see it shake either. Maybe it‘s a local/browser problem?
I get an error:
_interopRequireDefault is not a function
It seems that switching repeatedly between the CodeSandbox page and another full-window app triggers the jumping. I’m currently on Windows/Chrome
I tried a couple things (set mass
of child boxCollider.physicsImpostor
to 0 as recommended in Compound Bodies | Babylon.js Documentation, changed ground mesh to CreateBox
instead of CreateGround
, and replaced boxCollider
with physicsRoot
when setting linearDamping
and angularDamping
). These don’t seem to work for now, and I’ll try looking into this
I could stop the jumping by commenting out the line:
// boxCollider.physicsImpostor.physicsBody.linearDamping = .9;
but this may not be a good solution, since your car will now slide infinitely due to no friction
This is a matter of time. When getting back to the tab, the delta time is bigger than a rendering frame. like 100ms. So during the timestep for the physics world steps performs gravity for that amount of time. the body gets below the ground and is pushed as a physics response.
To fix that, change the physics plugin to not use the delta and set the time step to be fixed at 16ms.
I changed the physics initialization a bit: