What would be the right settings to run at 30FPS?
See original GitHub issueHi all!
I started to develop a small game with CannonJS. The game has to work on the server side (NodeJS) and Cannon is light enough for that purpose. The physics engine should run at 30FPS.
I noticed that CannonJS had not been maintained for a few years, so i decided today to migrate to Cannon-es because the project is more alive. I had to adapt my code to use the ES6 module with NodeJS. However, i have the same problems i had with CannonJS.
My decor is made with boxes and ramps (a custom shape). My charactere is made with a set of a wheel,a cylinder and a HingeConstraint.
My problem is that my character remains blocked/stuck in my decor especially during a jump. I will tend to think that this is due to a bad setting for 30FPS but i don’t enough know the physic engine to know which parameters to adapt (there are so many!). I took the parameters that i found as an example for CannonJS (i tried to change some parameters but without success). Maybe it’s due to a limitation of the physic engine?
var world = new CANNON.World();
world.quatNormalizeSkip = 0;
world.quatNormalizeFast = false;
world.defaultContactMaterial.contactEquationStiffness = 1e9;
world.defaultContactMaterial.contactEquationRelaxation = 4;
var solver = new CANNON.GSSolver();
solver.iterations = 7;
solver.tolerance =0.1;
world.solver = new CANNON.SplitSolver(solver);
world.gravity.set(0,-40,0);
world.broadphase = new CANNON.NaiveBroadphase();
world.broadphase.useBoundingBoxes = true;
var fixedTimeStep = 1.0 / 30.0; // seconds
var maxSubSteps = 3;
A screenshot of the problem:
What would be the right settings to run at 30FPS?
I created a small online demonstration to show the problem: https://littleworldofsatoshi.com/testRamp
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Thanks for your help.
In your specific case, you just have to make the ball bigger. This helps not falling through the ground. You can visualize the babylon mesh smaller if you want, and achieve the same result.
https://i.imgur.com/NkjoYNh.mp4
It’s not a specific science, you just have to play around with it man.
I’d suggest you using stack overflow next time, there are more people that can help you there.