Jump to content

Trigger event when two materials collide?


Recommended Posts

So I have player and walls as material. Wall collision is made in Tiled polylines. How I can trigger event every time, when player collides to walls?

        this.walls = this.game.physics.p2.convertCollisionObjects(this.map, 'Object Layer 1', true);        for (this.wall in this.walls)        {            this.walls[this.wall].setMaterial(this.wallMaterial);        }                this.layer1 = this.map.createLayer('Tile Layer 1');        this.collision = this.map.createLayer('Object Layer 1');

I tried to set postbroadphase callback like in example, but it is not working. I have tried to set collision to wall and collision. But it gives just error.

this.game.physics.p2.setPostBroadphaseCallback(this.restart, this);
restart: function (body1, body2) {if ((body1 === this.player && body2 === this.collision) || (body2 === this.player && body1 === this.collision))
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...