Sometimes Collision detection fails while using matter js

Hi guys,

I have a problem that I am facing. I am using matter js to make a pool like game (not exactly pool, but it looks like pool), in 2d. The thing is I am facing an issue where the balls some times just go out of the world bounds and sometimes even pass through each other.

This does not happen every time,

  • The going out of bounds issue occurs when the ball is close to the bounds and I strike it towards the world bounds.
  • The balls passing though each other occurs when the two balls are touching each other when striking.

The thing is that these issues do not occur every time. Only sometimes. I have searched for ways to counter this.

I tried using the scene.matter.set30Hz() and scene.matter.set60Hz(). They do not seem to help.

Does any one have any idea as how to solve this issue? Is it ok that I have asked this question here? Should I ask this in the matter js forum?

Update:
I was able to fix the world bounds issue by increasing the thickness of the worldbounds. I read about it in this post under Collision detection issues.

The issue where the balls pass through each other still remains, I can’t use the above approach of increasing thickness. Does any one have any idea as to how to solve this?

2 Likes

I don’t know about matter, but, if you search about tunneling on matter (if it do antitunneling physics). Maybe a problema with the ‘design’ of matter, that don’t has any algorithm to prevent tunneling.

Hi @cpusam, thanks for the suggestion. Searching up tunneling on matter js I was able to find some good resources online. Thanks, I will try and adopt a possible solution and I will update here.

I found this article while searching for tunneling. They too seem to be using thicker walls to prevent tunneling through walls. I will try and see the other methods they have adopted and see if those help as well.

Thanks again.

1 Like