markjsb Posted May 26, 2014 Share Posted May 26, 2014 This is purely a mobile issue, desktop is perfect. I have a platform game and unfortunately there are random instances when it just falls through the tilemap. It usually happens on the first play and then randomly on the third or fourth level. I've tried on Nexus 4 and Nexus 7 and it is the same. I've tried CocoonJS and same there. As I say works fine on desktop. Any ideas how I can get this working? Is a different physics worth trying (currently arcade physics)? Anyone else had this problem. Thanks for your help Link to comment Share on other sites More sharing options...
markjsb Posted May 26, 2014 Author Share Posted May 26, 2014 Update, it works fine in Nexus 7 through CocoonJS, very occasionally in the browser it screws up. So I think it's a problem with mobile, I chose this library because it had been developed specifically for mobile browsers. So again I ask anyone had issues running on mobile where physics are too strong and the player occasionally falls through the floor (tilemap)? Link to comment Share on other sites More sharing options...
j0hnskot Posted May 27, 2014 Share Posted May 27, 2014 Do you have low fps? I usually run on this kind of results when i got low fps, resulting to low checks per second. Link to comment Share on other sites More sharing options...
valueerror Posted May 27, 2014 Share Posted May 27, 2014 i have the very same problem with arcade physics on all devices.. even on desktops.. this never happened with p2 physics.. i would guess it's an arcade bug but i didn't find the time to investigate or report it.. Link to comment Share on other sites More sharing options...
Karma Octopus Posted May 27, 2014 Share Posted May 27, 2014 I also had this problem on my Android device (since performance is so bad). What I finally found out was that if I decreased the gravity enough this didn't happen any more, so it could be a good idea to try lowering the gravity and see if that helps. Link to comment Share on other sites More sharing options...
markjsb Posted May 27, 2014 Author Share Posted May 27, 2014 Thanks Karma Octopus. I increased the gravity because the physics take forever to bring the player back to ground, it just doesn't feel right. Looks like I might have to give P2 a try, better get reading... Link to comment Share on other sites More sharing options...
Noid Posted May 27, 2014 Share Posted May 27, 2014 Check this: http://docs.phaser.io/Phaser.Physics.Arcade.html#TILE_BIASIt fixes tunneling on lower fps but if you set it too high you character will also "climb" from the sides to the top. In my case I got good results with TILE_BIAS = 50 The problem is probably that arcade physics only checks for overlaps between the object and the tile in each frame, so on very low fps you object just teleports from one side of the tile to the other without ever touching it. http://en.wikipedia.org/wiki/Collision_detection#A_posteriori_.28discrete.29_versus_a_priori_.28continuous.29 Link to comment Share on other sites More sharing options...
markjsb Posted May 27, 2014 Author Share Posted May 27, 2014 Wow thanks Noid, just about to give this a go, your help is very much appreciated Link to comment Share on other sites More sharing options...
markjsb Posted May 27, 2014 Author Share Posted May 27, 2014 Just tested. No problems at all on Nexus 4 now running through Webview+ on CocoonJS. Only managed to get it fall out once on regular Chrome browser, so very pleased with that enhancement. For anyone else struggling with this issue, I added this code on the update function: this.game.physics.arcade.collide(this.sprite, this.layer);this.game.physics.arcade.TILE_BIAS = 50; Sprite = player and layer = tilemap layer Again many thanks to NOID, didn't know that existed and I don't think I'd have worked that out from the docs Link to comment Share on other sites More sharing options...
Noid Posted May 27, 2014 Share Posted May 27, 2014 I have it in the create function right after initializing the physics system. this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.physics.arcade.TILE_BIAS = 50;I think you just need to set it once. Now I reread to forum post where Rich mentioned TILE_BIAS and I noticed he also mentioned tilePadding which is set per sprite, but I never tried it so I don't know if it works better than TILE_BIAShttp://docs.phaser.io/Phaser.Physics.Arcade.Body.html#tilePadding Link to comment Share on other sites More sharing options...
markjsb Posted May 27, 2014 Author Share Posted May 27, 2014 Thanks Noid! Link to comment Share on other sites More sharing options...
Recommended Posts