Jump to content

Problem with Arcade Physics on mobile


markjsb
 Share

Recommended Posts

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

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

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

Check this: http://docs.phaser.io/Phaser.Physics.Arcade.html#TILE_BIAS

It 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

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  :D

Link to comment
Share on other sites

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_BIAS

http://docs.phaser.io/Phaser.Physics.Arcade.Body.html#tilePadding

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...