# Make two bodies NOT collisionable with each other

**URL:** <https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245>\
**Category:** Phaser 3\
**Created:** [February 15, 2019, 7:02pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245 "2019-02-15T19:02:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tico1711](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/tico1711/32/722_2.png) [@Tico1711](https://phaser.discourse.group/u/Tico1711)\
**Post date:** [February 15, 2019, 7:02pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/1 "2019-02-15T19:02:39Z")

</div>

Hi all

I am working with Matter in this. is there a way to make two “matter enabled” sprites not collide with each other?

What I want to achieve is to have one sprite on top of the other at ALL TIMES.

Thanks!

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [February 15, 2019, 7:17pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/2 "2019-02-15T19:17:41Z")

</div>

Add them to the same collisionFilter: group

```javascript
let group = this.matter.world.nextGroup(true)

let body = this.matter.add.image(x, y, 'image')
    body.setBody(
      {
        type: 'rectangle',
        width: width,
        height: height
      },
      {
        collisionFilter: {
          group: group
        },
      }

```

I’m not sure if you can use a phaser container in this case to stick both sprites together. Try it.

---

<div class="post-metadata">

**Author:** ![Tico1711](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/tico1711/32/722_2.png) [@Tico1711](https://phaser.discourse.group/u/Tico1711)\
**Post date:** [February 15, 2019, 7:36pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/3 "2019-02-15T19:36:35Z")

</div>

Makes sense now that you mention it.  
I gave it a go but when the game starts both sprites start going up and stays like that, colliding with the world’s upper bound.  
What did work is that both sprites are one on top of the other.

---

<div class="post-metadata">

**Author:** ![Tico1711](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/tico1711/32/722_2.png) [@Tico1711](https://phaser.discourse.group/u/Tico1711)\
**Post date:** [February 15, 2019, 7:48pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/4 "2019-02-15T19:48:36Z")

</div>

![Example](https://global.discourse-cdn.com/free1/uploads/phaser1/original/1X/cdea2fbd2340d532b405da5f4cbc06553c57d83b.gif)

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [February 15, 2019, 8:12pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/5 "2019-02-15T20:12:36Z")

</div>

Strange. Do you use other physical bodies in this game? Does the see background has a physical body?

Maybe you want to post a bit more of your code?

---

<div class="post-metadata">

**Author:** ![Tico1711](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/tico1711/32/722_2.png) [@Tico1711](https://phaser.discourse.group/u/Tico1711)\
**Post date:** [February 15, 2019, 8:23pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/6 "2019-02-15T20:23:32Z")

</div>

The only other collisionable is the tilemap, but not all of it, just the land tiles. It’s made collisionable with the setCollisionByProperty.  
Maybe I should open TILED, and make the water tile FALSE to collision (currently it does not have the property, I only created the property in Tiled for the land tiles).

---

<div class="post-metadata">

**Author:** ![Tico1711](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/tico1711/32/722_2.png) [@Tico1711](https://phaser.discourse.group/u/Tico1711)\
**Post date:** [February 16, 2019, 1:49pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/7 "2019-02-16T13:49:25Z")

</div>

> [@yannick](#):
>
> Strange. Do you use other physical bodies in this game? Does the see background has a physical body?
> 
> Maybe you want to post a bit more of your code?

So yannick, I managed to figure out the strange behaviour shown in the GIF (stupid begginer code mistake hehe).  
Now I have this group, with the two non collisionable bodies in it. What I see now is that the friction the boat had when moving is gone. I need the friction back so I can have a controlled movement of the ship. Do I have to set the friction to the group?

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [February 16, 2019, 2:00pm UTC](https://phaser.discourse.group/t/make-two-bodies-not-collisionable-with-each-other/1245/8 "2019-02-16T14:00:13Z")

</div>

I do not know if you can add a friction to the group. I have always added a friction to all bodies in a group individually.

Take a look at two classes I built with matter. Hope it helps.

- [Car Class](https://github.com/yandeu/phaser3-matter-car-on-curved-terrain/blob/master/src/scripts/objects/car.ts)
- [Bridge Class](https://github.com/yandeu/phaser3-matter-car-on-curved-terrain/blob/master/src/scripts/objects/bridge.ts)
