# Sometimes Collision detection fails while using matter js

**URL:** <https://phaser.discourse.group/t/sometimes-collision-detection-fails-while-using-matter-js/6165>\
**Category:** Phaser 3\
**Created:** [May 2, 2020, 7:42am UTC](https://phaser.discourse.group/t/sometimes-collision-detection-fails-while-using-matter-js/6165 "2020-05-02T07:42:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![123survesh](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/123survesh/32/2274_2.png) [@123survesh](https://phaser.discourse.group/u/123survesh)\
**Post date:** [May 2, 2020, 7:42am UTC](https://phaser.discourse.group/t/sometimes-collision-detection-fails-while-using-matter-js/6165/1 "2020-05-02T07:42:46Z")

</div>

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](https://codersblock.com/blog/javascript-physics-with-matter-js/) 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?

---

<div class="post-metadata">

**Author:** ![cpusam](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/cpusam/32/3136_2.png) [@cpusam](https://phaser.discourse.group/u/cpusam)\
**Post date:** [May 4, 2020, 3:46pm UTC](https://phaser.discourse.group/t/sometimes-collision-detection-fails-while-using-matter-js/6165/2 "2020-05-04T15:46:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![123survesh](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/123survesh/32/2274_2.png) [@123survesh](https://phaser.discourse.group/u/123survesh)\
**Post date:** [May 4, 2020, 6:41pm UTC](https://phaser.discourse.group/t/sometimes-collision-detection-fails-while-using-matter-js/6165/3 "2020-05-04T18:41:14Z")

</div>

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](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls-tunneling/1883/6) 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.
