Hi,
I want to collide my character only from top, because I want him to go from the left side, but my character always falls down from the world when i go form the left side. Problem it’s similar to How to allow tile collision only to the top? .Demo Below.
Hi,
this.map = this.add.tilemap('level2');
let tileset = this.map.addTilesetImage('lvl2_sprites', 'tilesetNameInPhaser');
this.floor = this.map.createStaticLayer('floor', [tileset], 0, 0);
this.player.body.setCollideWorldBounds(true); // <-- add this line so the player can't quit the map bounds
// collision
this.physics.add.collider([this.player], [this.floor]);
this.floor.setCollisionByExclusion(-1, true);
this.floor.tilemap.forEachTile((tile) => {
if (tile.properties.collidesTop) {
tile.setCollision(false, false, true, false);
}
})
Yeah, but the problem is that my character falls down when collides tiles, I don’t know why