# Matter.js : how to have collision event between two object static?

**URL:** <https://phaser.discourse.group/t/matter-js-how-to-have-collision-event-between-two-object-static/7037>\
**Category:** Phaser 3\
**Created:** [July 28, 2020, 6:41pm UTC](https://phaser.discourse.group/t/matter-js-how-to-have-collision-event-between-two-object-static/7037 "2020-07-28T18:41:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [July 28, 2020, 6:41pm UTC](https://phaser.discourse.group/t/matter-js-how-to-have-collision-event-between-two-object-static/7037/1 "2020-07-28T18:41:43Z")

</div>

Hi,

I would like to know how to have collision event between two object static ?  
This snippet don’t works, could you help me ?

Thanks

```
var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#1b1464',
    parent: 'phaser-example',
    physics: {
        default: 'matter',
        matter: {
            gravity: {
                x: 0,
                y: 0
            }
        }
    },
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.image('block', 'assets/sprites/block.png');
}

function create ()
{
    var blockA = this.matter.add.image(590, 300, 'block').setStatic(true);;

    var blockB = this.matter.add.image(600, 300, 'block').setStatic(true);

    this.matter.world.on('collisionstart', function (event, bodyA, bodyB) {

        bodyA.gameObject.setTint(0xff0000);
        bodyB.gameObject.setTint(0x00ff00);

    });
}
```

---

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [July 29, 2020, 1:49pm UTC](https://phaser.discourse.group/t/matter-js-how-to-have-collision-event-between-two-object-static/7037/2 "2020-07-29T13:49:28Z")

</div>

i try with .setSensor(true) but that don’t works…anybody ?

```
var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#1b1464',
    parent: 'phaser-example',
    physics: {
        default: 'matter',
        matter: {
            gravity: {
                x: 0,
                y: 0
            }
        }
    },
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.image('block', 'assets/sprites/block.png');
}

function create ()
{
    var blockA = this.matter.add.image(499, 300, 'block').setBounce(1).setFriction(0).setStatic(true).setSensor(true);

    var blockB = this.matter.add.image(600, 300, 'block').setStatic(true).setSensor(true);;

   // blockA.setVelocityX(10);

    this.matter.world.on('collisionstart', function (event, bodyA, bodyB) {

        bodyA.gameObject.setTint(0xff0000);
        bodyB.gameObject.setTint(0x00ff00);

    });
    window.setTimeout(()=>{
        blockA.setPosition(510,250)
    },1000)
}
```

---

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [July 29, 2020, 1:51pm UTC](https://phaser.discourse.group/t/matter-js-how-to-have-collision-event-between-two-object-static/7037/3 "2020-07-29T13:51:43Z")

</div>

with a jsfiddle it’s more easy to see what’s wrong :  
[https://jsfiddle.net/espace3d/z51djsxk/33/](https://jsfiddle.net/espace3d/z51djsxk/33/)
