# Matter one way collision

**URL:** <https://phaser.discourse.group/t/matter-one-way-collision/6432>\
**Category:** Phaser 3\
**Created:** [May 25, 2020, 12:04pm UTC](https://phaser.discourse.group/t/matter-one-way-collision/6432 "2020-05-25T12:04:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [May 25, 2020, 12:04pm UTC](https://phaser.discourse.group/t/matter-one-way-collision/6432/1 "2020-05-25T12:04:10Z")

</div>

Hi.  
How to implement one way collision using matter physics.  
@BlunT76  
Thank you

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [May 25, 2020, 2:23pm UTC](https://phaser.discourse.group/t/matter-one-way-collision/6432/2 "2020-05-25T14:23:40Z")

</div>

Hi,  
I never used Matter physics, only arcade. Did you look in the docs?

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [May 25, 2020, 3:57pm UTC](https://phaser.discourse.group/t/matter-one-way-collision/6432/3 "2020-05-25T15:57:53Z")

</div>

i am looking into it. for now i didn’t get anything bro. @BlunT76

---

<div class="post-metadata">

**Author:** ![ajay](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@ajay](https://phaser.discourse.group/u/ajay)\
**Post date:** [May 26, 2020, 4:09pm UTC](https://phaser.discourse.group/t/matter-one-way-collision/6432/4 "2020-05-26T16:09:18Z")

</div>

[SOLVED]

by using collision groups we can achieve one way collision .

first you have to create collision groups.  
this.group1 = this.matter.world.nextGroup(); //gameObjects in this group will collide with one another

this.group2 = this.matter.world.nextGroup(true);//by  
setting the flag true .gameObjects in this group wont collide with each other

now you can assign them to different objects.  
obj1.setCollisionGroup(this.group1); //example code  
obj2.setCollisionGroup(this.group1); //example code

now by putting condition in update function.by changing the collision group we can get our required functionality.

example given by phaser will help you  
[https://labs.phaser.io/edit.html?src=src\physics\matterjs\collision%20group.js](https://labs.phaser.io/edit.html?src=src%5Cphysics%5Cmatterjs%5Ccollision%20group.js).

Thank you.
