How to allow tile collision only to the top?

What I wanted to achieve here is, I want the sprite to overlap tiles and only collide when the sprite is on top of tiles.

I can’t find a tutorial for this kind of stuff, so I am asking you all to aid and enlighten me.

I guess you could use setCollision().

1 Like

In this example (typescript) I iterate all map tiles (only once) and then assign a custom collide only on the tiles with the property customCollide true.
The property customCollide is a custom property assigned to certain tiles using Tiled editor. Phaser.Tilemaps.Tile) => {
if ( != undefined) {
tile.setCollision(false, false, true, false, true);
}, this);

I have exacly same problem, but my character fall down from the map when i move him on the right. Anybody has fix for this? When tiles with ‘collideTop’ property are upper this works fine :confused:


Assuming you’re creating your platforms with Tiled Editor on a tile layer called “platofrms” and you’ve assigned the tile property name name “jumpThrough” for tiles that you want to be collid-able only from the top, something like this should work:

this.platforms = map.createLayer("platforms", null, 0, 0);
this.platforms.setCollisionByExclusion(-1, true);

this.platforms.forEachTile(tile => {
      if ( === "jumpThrough") {
        tile.setCollision(false, false, true, false);

It isn’t working. My player always fall down when I move. This is my code: = this.add.tilemap('level2');
        let tileset ='lvl2_sprites', 'tilesetNameInPhaser');
        this.floor ='floor', [tileset], 0, 0);    
        // collision    
        this.physics.add.collider([this.player], [this.floor]);
        this.floor.setCollisionByExclusion(-1, true);
        this.floor.tilemap.forEachTile((tile) => {
            if ( {
                tile.setCollision(false, false, true, false);