Pass-through Platforms


Today I'm adding a very common feature in most platformer games -- a type of ground or platform that you can stand on top of, but also jump to from below (some games also let you jump down, through it, by pressing down, but I'm not doing that).


Ignore that chest...

For this, all I have had to do is to make sure that when the player is colliding from below, the collision is OFF, and once the player has cleared the platform or is just above it, turn it ON. This has been okay, but I have learnt a very important thing that I did not think too much about: The order in which functions are laid out.

I had this working on the first 30 minutes, and have spent another 30 minutes figuring out why sometimes the player would fall through. This is because of the amount of clearance space I was setting up above a platform. If I had two platforms 1 grid (16px) above each other, when stepping on the bottom one the player would always fall through because the clearance was set to 18px so it was hitting the platform above. The player is 10px high so I set the clearance to that same height and it works flawlessly now.

The more you know!

Leave a comment

Log in with itch.io to leave a comment.