"One-Way" and "Pass-Thru" platforms in Phaser 3

Continuing my exploration of various mechanisms in platform games, this time it’s about implement “one-way” platforms (i.e. those platforms that you can jump “through” from the bottom but can land on top) and “Pass through” platforms, i.e. those ones where you can fall through by pressing down.

I have created example code using Arcade Physics Sprites, and documented my findings here.

and also cover the same topic using tile maps, documented here.

image

I have used Arcade Physics.

2 Likes

Here are the tile collision directions:

1 Like

Thank you Samme!
Your addition makes it so much easier to illustrate the idea I am trying to share!

What is interesting (I didn’t know until I saw your debug lines) is that for tiles set to collide via
this.platforms.setCollisionByProperty({collides: true});, all the 4 faces, including the non-interesting faces have their collision flag set to true.

I had done a “fall-through” mechanic (press down when standing on a platform) by briefly toggling the player’s checkCollision.down:

function drop() {
  player.setVelocityY(150);
  player.body.checkCollision.down = false;
}

function dropExpire() {
  player.body.checkCollision.down = true;
}

It’s not quite correct since it would affect other collisions (collecting stars), but it’s quite easy to do.

I see - you are cancelling collisions on the player sprite as opposed to the platform, and restoring it 200ms later. As you say it will affect other collision detection for that 0.2 seconds, albeit only in the vertical collision detection I guess. My version would also suffer from other unintended objects passing through the platform too…I hadn’t thought of that.