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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.