Zampano Posted May 12, 2017 Share Posted May 12, 2017 Hello everyone, I've got a very odd problem with the collision detection of the arcade physics system. The code is as follows: var x_player = null; var floor = null; BasicGame.Game.prototype = { preload: function () { }, create: function () { this.physics.startSystem(Phaser.Physics.ARCADE); var boundary_bottom = 650; var boundary_top = 50; floor = this.add.sprite(640, 680, 'floor'); floor.anchor.setTo(0.5, 0); x_player = this.add.sprite(640, 450, 'x_player'); x_player.anchor.setTo(0.5, 0.5); this.physics.arcade.enable([floor, x_player]); floor.body.allowGravity = false; floor.body.immovable = true; x_player.body.gravity.y = 600; x_player.body.bounce.y = 0.4; x_player.body.setCircle(27,9,9); }, update: function () { this.physics.arcade.collide(x_player, floor); if (this.input.activePointer.isDown) { x_player.body.velocity.y = -500; } }, render: function () { this.game.debug.body(x_player); this.game.debug.body(floor); } }; The collision detection seems to work basically, but when I let the ball jump by pressing the mouse button, there is a pretty big random chance it will just slip through the floor when it comes down again. It seems like it doesn't work precisely enough or something. Does anyone know more? Help is greatly appreciated! Link to comment Share on other sites More sharing options...
samme Posted May 13, 2017 Share Posted May 13, 2017 You might try the latest Phaser CE (if you're not using it already). It improved collision checks on circular bodies. Zampano 1 Link to comment Share on other sites More sharing options...
Zampano Posted May 14, 2017 Author Share Posted May 14, 2017 Thank you, works like a charm Link to comment Share on other sites More sharing options...
Recommended Posts