matter-js
matter-js copied to clipboard
Error causes physics to speed up and collisions stop working
I'm working on this game and there's a bug that happens sometimes which causes this error to happen in the console:
![](https://user-images.githubusercontent.com/62298468/180443671-edb0ad9e-761b-4f6d-be89-093cd95fd57f.png)
Basically this error happens when a non-static body collides with a static one.
How to reproduce
At first I didn't know what caused it but now I found a way to make this error:
- Open my game
- Go into creative mode
- Turn on static in the bottom right corner
- Drop a few static blocks
- Turn off static in the bottom right corner
- Drop a non-static block on top of a static one
That causes the error to appear in the console. It also makes all of the physics run faster and collisions stop working. Also sometimes the static body and the non-static body that collided disappear.
Are you able to share a minimal code case for this one? Thanks.
I don't really know why it even happens, and I've tried to replicate it but I can't. I can only get it to happen in my game, which has a lot of irrelevant code. But I'll keep looking...
I encountered the same issue. Did you solve it later?
Nope, issue still exists.
In my case, the error was caused by setting the radius of a high-precision floating-point value for a Cricle Body.
So I add Math.round
and it works fine.
// radius = 1.123456789...
Math.max(Math.round(radius), 1)