Open rbozan opened 9 years ago
Yes, this is a drawback of having discrete collision detection. You have to cap the max velocity of objects or use higher FPS.
A solution for this is to use continuous collision detection (CCD), and I've been experimenting with a raycasting based CCD in my 2d physics engine p2.js. But for this to work in Cannon.js, it would require the raycasting to work well and performant. A bit of work to get there in other words.
15 fps, really? That is very low for a physics simulation. Why such low fps?
Well, just for testing purpose I guess. I'm unsure how good the performance of this library is though. It of course can run higher than 15 fps, but on how much objects can you see some drawbacks?
Well.. That number depends a lot on what your scene contains, how many bodies, what type of shapes, how many contacts, etc, etc. So you'll have to test it for your specific use case.
I found that using 30fps was fine for me. I tried with 10fps at first and objects would fall through my ground plane as well. Using 30fps everything is fine for me with a gravity of Y=-9.
Basically, I have a NodeJS server set up where cannon does all the calculations. I have setted up the step to 15 fps. The step will call 15 times per second. However, this makes high velocity objects fall through other objects.
The only "solution" I can see is run on a higher FPS. This would lessen the effect but it would still happen if you have really high velocity objects.