# Prevent objects from passing through walls

**URL:** <https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206>\
**Category:** Phaser 2 / CE\
**Created:** [November 24, 2020, 5:27am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206 "2020-11-24T05:27:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nilesh\_Shripal](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nilesh_shripal/32/1127_2.png) [@Nilesh\_Shripal](https://phaser.discourse.group/u/Nilesh_Shripal)\
**Post date:** [November 24, 2020, 5:27am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/1 "2020-11-24T05:27:47Z")

</div>

Hello there, I’m developing carrom board game using Arcade Physics. In which when I hit black or white rings of carrom using striker then ring passes through walls of carrom. How to prevent it from passing it through walls ?  
Sorry for my bad English.

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [November 24, 2020, 5:58am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/2 "2020-11-24T05:58:59Z")

</div>

> **[Phaser 3 How To Prevent Sprites Overlapping And Tunnelling](https://www.stephengarside.co.uk/blog/phaser-3-how-to-prevent-sprites-overlapping-and-tunnelling/)**
>
> Read how to quickly and easily prevent sprites from overlapping / tunnelling during collision detection. 1 Min Read.

---

<div class="post-metadata">

**Author:** ![Nilesh\_Shripal](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nilesh_shripal/32/1127_2.png) [@Nilesh\_Shripal](https://phaser.discourse.group/u/Nilesh_Shripal)\
**Post date:** [November 24, 2020, 6:05am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/3 "2020-11-24T06:05:58Z")

</div>

Thanks for reply. I tried it. but did not helped. I’m working on Phaser v2.9.2

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [November 24, 2020, 6:20am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/4 "2020-11-24T06:20:31Z")

</div>

Then you can try setting OVERLAP\_BIAS higher than 4.  
Or use P2, where you can set frameRate.

---

<div class="post-metadata">

**Author:** ![Nilesh\_Shripal](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nilesh_shripal/32/1127_2.png) [@Nilesh\_Shripal](https://phaser.discourse.group/u/Nilesh_Shripal)\
**Post date:** [November 24, 2020, 6:57am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/5 "2020-11-24T06:57:43Z")

</div>

> [@Milton](#):
>
> OVERLAP\_BIAS

OVERLAP\_BIAS did not worked. P2 does not have this kind of issue ?

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [November 24, 2020, 7:12am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/6 "2020-11-24T07:12:08Z")

</div>

Your pieces must be moving pretty fast then 🙂 What values did you try?

P2 has the exact same issue, every collision detection library has the same problem to solve.  
But with P2 you can set the physics frameRate. If you double it, twice as many collision checks will be done.  
Or you need an engine like Bullet (Ammo.js), that has CCD (continuous collision detection). CCD ensures that fast-moving bodies collide with objects instead of passing, or tunnelling, through those objects.

---

<div class="post-metadata">

**Author:** ![Nilesh\_Shripal](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nilesh_shripal/32/1127_2.png) [@Nilesh\_Shripal](https://phaser.discourse.group/u/Nilesh_Shripal)\
**Post date:** [November 24, 2020, 8:49am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/7 "2020-11-24T08:49:40Z")

</div>

> [@Milton](#):
>
> Ammo.js

I used s.body.maxVelocity .setTo(150, 150);

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [November 24, 2020, 9:00am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/8 "2020-11-24T09:00:44Z")

</div>

Hmm, that shouldn’t be a problem. That gives a maximum of about 3.5 pixels when moving diagonally at 60 fps.

Did you try game.physics.arcade.OVERLAP\_BIAS = 16; (or even higher?)

---

<div class="post-metadata">

**Author:** ![Nilesh\_Shripal](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nilesh_shripal/32/1127_2.png) [@Nilesh\_Shripal](https://phaser.discourse.group/u/Nilesh_Shripal)\
**Post date:** [November 24, 2020, 9:01am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/9 "2020-11-24T09:01:49Z")

</div>

Yes, I tried it.

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [November 24, 2020, 9:08am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/10 "2020-11-24T09:08:27Z")

</div>

I’m out of suggestions. Maybe you could put some code online somewhere that shows the basic problem.

Or go for P2, and keep increasing the framerate until it works. But your speed should not be a problem…

---

<div class="post-metadata">

**Author:** ![Nilesh\_Shripal](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nilesh_shripal/32/1127_2.png) [@Nilesh\_Shripal](https://phaser.discourse.group/u/Nilesh_Shripal)\
**Post date:** [November 24, 2020, 9:10am UTC](https://phaser.discourse.group/t/prevent-objects-from-passing-through-walls/8206/11 "2020-11-24T09:10:14Z")

</div>

Okay. Thanks for your support.
