ekeimaja Posted December 1, 2015 Share Posted December 1, 2015 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 More sharing options...
san40511 Posted December 1, 2015 Share Posted December 1, 2015 U can use.body1.blocked.left , body1.blocked.right,body1.blocked.down,body1.blocked.up - it depends from which side you need to check. Link to comment Share on other sites More sharing options...
ekeimaja Posted December 2, 2015 Author Share Posted December 2, 2015 That is for arcade physics, so it does not work for p2. Link to comment Share on other sites More sharing options...
ekeimaja Posted December 7, 2015 Author Share Posted December 7, 2015 So is there anything solution for this, or is only way to get this work to modify whole engine? Link to comment Share on other sites More sharing options...
Recommended Posts