phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Collide Down from Below problem

Open zzox opened this issue 8 years ago • 2 comments

Version

  • Phaser Version: 3.13
  • Operating system: Mac OSX
  • Browser: Google Chrome

Description

Using Arcade Physics, I am colliding with the tiles from below, after setting them to only collide "down" item.setCollision(false, false, true, false) . Once the player starts to go down while they are overlapping the tile, the physics engine sets them on top of the tile, when this should only happen when they are colliding with them from above.

Example Test Code

This is the applicable code:

create(){
  this.contactTileSet = this.map.addTilesetImage('town-groundLayer', 'town-groundLayer-tiles')
  this.groundLayer = this.map.createDynamicLayer('groundLayer', this.contactTileSet, 0, 0)
  this.groundLayer.setCollisionByProperty({ collide: true })
  this.groundLayer.filterTiles(item => {
    if(item.properties.collideDown === true){
      item.setCollision(false, false, true, false)
    }
  })
}

Additional Information

In the following gif you can see the player start his decent on the final jump, before he is placed at the top of the tile.

2018-09-30 15 38 58

zzox avatar Oct 02 '18 02:10 zzox

I think this may be correct. As long as the player is overlapping a tile with checkCollision.down while moving down he can be separated on the top edge during a collision. It doesn't matter if most of the overlap is below the tile instead of a above.

You may be able to reduce TILE_BIAS (smaller than half the tile height?) to avoid that.

samme avatar Oct 02 '18 03:10 samme

Setting TILE_BIAS to 4 ended up working. I will have to test a few different scenarios to make sure it doesn't cause other problems but for now my issue is gone. Thanks!

zzox avatar Oct 02 '18 13:10 zzox