Sign in to follow this  
clguy

Jump through a tile from underneath

Recommended Posts

Hi!

I’m new to Phaser 3 and I’m testing a lot of things to create a little platformer, right now I’m using Tiled, and I already did tiles that collide with the player, but I don’t know how to avoid colliding with the bottom part of these tiles. So I’m asking for help.

 

Thanks.

Share this post


Link to post
Share on other sites

Hey, if you use arcade physics, you can do this:
 

const map = this.make.tilemap({ key: key, tileWidth: 12, tileHeight: 12}); 
// init the tilemap, setup the right tile sizes
const levelTiles = map.createDynamicLayer(2, tileset, 0, 0); //setting up a new tilemap layer
//I think note doesn't matter if it's static ot dynamic for your purpose

levelTiles.layer.data.forEach((row) => { // here we are iterating through each tile.
			row.forEach((Tile) => {
				switch(Tile.index) { // the index, you can see in tiled: it's the ID+1
					case 31: Tile.visible = false; break;
					case 485: // <- this tile only colides top
						Tile.collideDown = false;
						Tile.collideLeft = false;
						Tile.collideRight = false;
						break;
					case 545: // <- this tile only colides top
						Tile.collideDown = false;
						Tile.collideLeft = false;
						Tile.collideRight = false;
						break;
					default: break;
				}
			})
		});

Hope that this will helps :)
If you got any questions, don't hesitate to ask.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.