Search the Community
Showing results for tags 'setpostbroadphasecallback'.
-
Hello, I was using Arcade physics and the collisions were working perfectly fine when defined as physics.arcade.collide. In my game, I have an AI character moving in a straight line, flipping direction when colliding with walls. Walls are defined in a layer, with a custom property 'collision' set to true. (defined in Tiled). I had to switch to P2 physics as I needed more sophisticated collisions for some objects that had polygon shapes, and also had to use something that P2.Spring defines. With P2, when my AI collides with the walls it bounces back in XY direction - while the ideal behaviour is that with - this.body.velocity.x *= -1; OR this.body.velocity.y *= -1; - It should only remain on its axis. I thought I would solve it by checking collision bodies in setPostBroadphaseCallback but that does not seem to work as desired or may be I am missing something very obvious. if(body1 != null && body1.sprite != null && body1.sprite.key === 'enemy'){ // I would want to check body2 as I do body1 but for my tile body2.sprite is NULL. } I even tried comparing with each wall body gotten from the below method - this.walls = this.game.physics.p2.convertTilemap(this.map, this.layers[layer.name]); The walls collision is defined as below - for(var i=0; i<this.walls.length; i++){ this.walls.setCollisionGroup(this.collision_groups["wallCG"]); this.walls.collides(this.collision_groups["playerCG"]); this.walls.collides(this.collision_groups["enemyCG"]); } Is there a way that I would know the collision group of body2? OR compare collision groups and not body1 and body2 in setPostBroadphaseCallback? Please help. It's urgent. Thanks in advance! agogiam
-
- tiled
- collision with a tile layer
-
(and 1 more)
Tagged with:
-
Video of issue: https://www.dropbox.com/s/td88t29bxq7jwqk/Phaser-wrong-overlaping.mov?dl=0 Background should change when zone and gift are overlapped but setPostBroadphaseCallback fire event on wrong time. I think It happens maybe because zone looks like a rectangle... This is code for the video you see above: http://paste.ofcode.org/QE7KjbDy4bXLLYNQDKDDnY
- 1 reply
-
- phaser
- setPostBroadphaseCallback
-
(and 2 more)
Tagged with: