huridloag Posted January 14, 2015 Share Posted January 14, 2015 Hi, I'm using Phaser (2.2.1) to make my first game, a platformer. Arcade physics to do the collision detection; Tiled to make the map. The problem I'm having is that the player occasionally passes through a platform when descending from a higher point (after jumping for example). Here are what I think are the relevant bits of code: Create:this.gravity = 2200;this.blockedLayer = this.map.createLayer('blockedLayer');this.map.setCollisionBetween(1,10000,true,'blockedLayer');this.player = this.add.sprite(200,200,'player');this.player.anchor.setTo(0.5,1);this.physics.arcade.enable(this.player);Update:this.game.physics.arcade.collide(this.player,this.blockedLayer);So to repeat -- it's working most of the time, but 1 jump in 8 results in the player falling down through a platform (including through the floor on occasion). Following the advice in this post I tried playing with TILE_BIAS but it just made the player act freaky around the platforms... Has anyone had this problem before? Any ideas how to fix it much appreciated. Link to comment Share on other sites More sharing options...
irok84 Posted January 15, 2015 Share Posted January 15, 2015 Similar problem here, but with moving sprites, not level tiles. https://www.youtube.com/watch?v=7beTqZVm5f4&feature=youtu.be Link to comment Share on other sites More sharing options...
irok84 Posted January 15, 2015 Share Posted January 15, 2015 Try to set player.body.bounce.y = 0; It helped me in collisions with "world" tiles. Link to comment Share on other sites More sharing options...
Massemassimo Posted January 15, 2015 Share Posted January 15, 2015 Have the same problem, no solution yet (other than to make a top down game ) Link to comment Share on other sites More sharing options...
valueerror Posted January 15, 2015 Share Posted January 15, 2015 constant tunneling was one of the reasons why i changed to p2 physics.. i thought this issue was adressed in the newest version of phaser for arcade physics?! Link to comment Share on other sites More sharing options...
eternalthinker Posted January 15, 2015 Share Posted January 15, 2015 Observing the same problem with my first Phaser game! (a Flappy bird clone made as a B'day wish ) Here the ground is a tileSprite with autoScroll on, and then there's the bird sprite. Collision is enabled in update() as:game.physics.arcade.collide(this.bird, this.ground, this.hitGround, null, this);Every once in a while the bird falls right through the ground. The player gravity is set to 1000. The working game (and source) can be viewed here: https://eternalthinker.github.io/flappy-birthdayIf you let the player fall in the beginning itself, you'll see this issue with a good probability. For the purposes of this game, this isn't a blocking issue, but I do worry about more complex games in the future Link to comment Share on other sites More sharing options...
Massemassimo Posted January 16, 2015 Share Posted January 16, 2015 @valueerror yes, the problem was adressed, but for me, updating didn't solve the problem. Link to comment Share on other sites More sharing options...
huridloag Posted January 20, 2015 Author Share Posted January 20, 2015 @eternalthinker: I couldn't reproduce your problem with falling thru the ground. Did you fix it eventually? @valueerror: Great - so does P2 Physics fix the problem then? For those of you with more experience than me, is there any reason why changing to P2 physics isn't a good idea, compared to Arcade physics? Thanks! Link to comment Share on other sites More sharing options...
valueerror Posted January 20, 2015 Share Posted January 20, 2015 p2 still doesn't do continuous collision detection (i guess because it's a bad idea in general when it comes to performance) but tunneling in p2 only occurs at a very very high object speed against very thin walls... some say that p2 physics is heavy but it actually depends on what features of p2 you use... also some very convenient functions you know from arcade are not there like "touching.down" but there is a (custom) replacement for everything Link to comment Share on other sites More sharing options...
huridloag Posted January 20, 2015 Author Share Posted January 20, 2015 Thanks @valueerror -- that's very useful. I guess I need to look into this more broadly, in terms of the different kinds of collision detection, the best engine to use for making a platformer, etc. If Phaser, or HTML5/JS in general, can't cope with the tunnelling issue, maybe I need to look elsewhere. Link to comment Share on other sites More sharing options...
valueerror Posted January 20, 2015 Share Posted January 20, 2015 p2 can cope with tunneling as much as every other physics engine out there... (except the ones that support CCD but they also state to only activate it if absolutely necessary because it's so bad for performance)tunneling isn't a new problem .. it's the logical thing that occurs when the speed is to high.. the arcade physics slipthrough is something different i guess.. i had this problem with arcade and it felt like collision was suddenly deactivated completely no matter how thick the ground was .. i slipped through.. here are some graphics to explain it http://www.stencyl.com/help/view/continuous-collision-detection/ Link to comment Share on other sites More sharing options...
huridloag Posted January 20, 2015 Author Share Posted January 20, 2015 That stencyl page is very clear, thanks! It's true that the problem only occurs for me when the player's falling, and my gravity is set pretty high, but it makes for a nice snappy feel to his movements. This makes me think that even on arcade the problem *is* tunnelling, despite what you're saying about the thick ground. But I'm totally new to this, so I have no idea. I'll try p2. Grateful for the feedback. valueerror 1 Link to comment Share on other sites More sharing options...
Massemassimo Posted January 22, 2015 Share Posted January 22, 2015 Yes, arcade definitely still has some issues in that department! But afaik you can use p2 with phaser, so you don't need to switch everything, just the physics. Link to comment Share on other sites More sharing options...
TNelson Posted December 11, 2016 Share Posted December 11, 2016 I am still having this ish. Is the solution basically just to switch to P2 then? Link to comment Share on other sites More sharing options...
Recommended Posts