Jump to content

2.0 arcaded tile collision issue


kass
 Share

Recommended Posts

Im using 2.0 arcade physics for a platformer i'm making but my player keeps colliding with invisible overhead tiles , running through tiles ,and sinking into the floor. I've tried changing around numbers in my setCollisionBetween and setCollisionByExclusion but collision detection is all over the place. I never really ran into this problem with the earlier phasers.

Its to the point where the game is kinda unplayable.

 

The links below are to hastebin.com

Here is my tilemap.json. I only want the player to collide with "ground"
And here is my actual game code game.js
 
is there anything i can do to fix this?
Link to comment
Share on other sites

  • 1 month later...

My team did a game for LD48, and we ran into the same issue with falling through the tiles. We also noted that if you tab out when your character is standing on a collision tile, then tab back in, he falls through them. Here's our working theory:

 

Slowing the character's movement speed down reduced the error rate, and they fell through less often. Anything that caused the framerate to drop also increased the error rate. So, we think that a condition occurs in which the physics operation pulls the character through the collision plane (in this case the edge of the tile), and when the engine detects the overlap it just returns false on collision and they continue to fall through. I haven't been able to deep dive into the code yet, but we think that a potential solution is to check for this state and if the player sprite has moved through the collision tile, the engine should handle it by repulsing them back to the edge. We'll continue to investigate and update you with our progress.

Link to comment
Share on other sites

I'm not sure I've solved it for a 100% of the cases, but in my particular case, turning TILE_BIAS up to 40 was the magic number. Here's how we implemented collision: 

this.game.physics.arcade.TILE_BIAS = 40;this.game.physics.arcade.collide(this.player.sprite, this.ground);

In our case, this.ground is defined as a layer from the tilemap before this:

map = this.add.tilemap('levelTileMapFromTiled');this.ground = map.createLayer('Ground');map.setCollision([2, 3, 4, 6, 7, 8, 10, 11, 12], true, this.ground);

It seems to be doing the trick so far, let me know if this helps!

Link to comment
Share on other sites

The "magic" value seems to be dependent on content – I found that 27 works for my combination of assets and settings, while at 40 (28 and up, actually) my character is placed on top of ledges he shouldn't be able to reach when he jumps into them from below (the ledges only collide with stuff above them).

 

TILE_BIAS of 2 is pretty hilarious, btw. And a good simulator of what it looks like in Firefox, where the frame rate is lower ;)

Link to comment
Share on other sites

My tiles are 32x32 so I think that might be a factor: 39 was too few. The weird thing is I could jack it up to 90 and everything settled but every now and again velocity would make my character slide up walls, which was actually kind of neat. Might be interesting to investigate some of these physics engines in hybrid formats. =D

Hope it helped!

 

The "magic" value seems to be dependent on content – I found that 27 works for my combination of assets and settings, while at 40 (28 and up, actually) my character is placed on top of ledges he shouldn't be able to reach when he jumps into them from below (the ledges only collide with stuff above them).

 

TILE_BIAS of 2 is pretty hilarious, btw. And a good simulator of what it looks like in Firefox, where the frame rate is lower ;)

Link to comment
Share on other sites

  • 2 months later...

I'm not sure I've solved it for a 100% of the cases, but in my particular case, turning TILE_BIAS up to 40 was the magic number. Here's how we implemented collision: 

this.game.physics.arcade.TILE_BIAS = 40;this.game.physics.arcade.collide(this.player.sprite, this.ground);

In our case, this.ground is defined as a layer from the tilemap before this:

map = this.add.tilemap('levelTileMapFromTiled');this.ground = map.createLayer('Ground');map.setCollision([2, 3, 4, 6, 7, 8, 10, 11, 12], true, this.ground);

It seems to be doing the trick so far, let me know if this helps!

Thanks a bunch, this issues was bugging me and this simple fix cured the problem right away. Good work.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Sorry for bringing this solved thread up, but could anyone explain the "magic" behind the TILE_BIAS attribute? Is that used as interpolation to compute collisions?

Hi, i think its about time dependent game loop. When updating position of game objects, you use something like x+=xVelocity*delta, where delta is time between this and previous update. When delta is too big, game object can go through ground, no colision detected. Big delta time can happened, when you dont have enough cpu power, or low priority of execution your game engine code, because switching tabs of your browser or high load of another programs. Try to underclock your cpu, and allow only 1 core for your browser, and /or stress you cpu by some benchmark program, while testing game, it give you object moving through too, because reasons written above.

You can fix it by lower count of tiles(tiles width and height will be bigger, bigger collision area, so lower chance to go through), lowering movement speed of your objects, or set the maximum allowed delta time( delta*velocity of object cant be bigger than size of another coliding object). Another option is loop between current position and position of your object in previous update, but it cost more cpu power.

Hope this helps.

Link to comment
Share on other sites

  • 10 months later...
  • 2 years later...
On 8/15/2015 at 7:41 AM, justGoscha said:

Does anyone know why I can't set 


game.physics.arcade.TILE_BIAS = 40;

 in typescript? It always says


Property 'TILE_BIAS' does not exist on type 'Arcade'.

Is it because TILE_BIAS is defined as static?

Happens the same with me! TILE_BIAS doesn't exist anymore or not accesible publicly through game.physics.arcade. What should we do now?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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