Posts > Building Game with Phaser: Player and Ladder
June 1, 2026
I’ve found this great article on google verse about how to implement player climbing ladder. It’s very straight forward particularly the first example. The author make use of switch case statement to check if the player status is climbing, walking or jumping then made a lot of rules if what to do if player is on or inside the ladder ( read the article it's much more than what I wrote ).
Though I have different setup, I didn’t really use switch case statement and just make use of if else so I ended up spaghetti code ( you’re welcome ).
When you want to make to object clash you use collide if you’re just passing trough use overlap . But ladder? it overlaps and collides. Collide with the top of the ladder so player can stand on them, overlap so player can walk through them and climb them.
I used the helper function from the example in the article, to check if the player is on top ladder.
onLadderTop(player, ladder) {
if (
player.body.bottom - player.body.deltaY() <= ladder.body.top &&
!this.cursor.down.isDown
) {
return true;
} else {
return false;
}
}and add onLadderTop check as process callback to check whether the player is on top of ladder or not.
this.physics.add.collider(
this.player,
this.ladderObject,
null,
this.onLadderTop,
this,
);For overlap I continuously check them in update() if the player and ladder object are overlapping / touching.
const touchingLadder = this.physics.overlap(this.player, this.ladderObject);To actually climb the ladder player object gravity is set to false and velocityX to 0 when in the zone / inside the ladder.
if (this.isClimbing) {
this.player.body.setAllowGravity(false);
this.player.body.setVelocityX(0);
} else {
this.player.body.setAllowGravity(true);
}Need to initialize the this.isClimbing so that we can pass this status to the player object and allowing us to move into the zone up and down.
this.playerController.update(this.cursor, this.isClimbing);Then when isClimbing = true we can make the player move with up and down.
if (isClimbing) {
if (cursor.up.isDown) {
this.player.setVelocityY(-80);
this.player.anims.play('climb', true);
} else if (cursor.down.isDown) {
this.player.setVelocityY(80);
this.player.anims.play('climb', true);
} else {
this.player.setVelocityY(0);
}
return;
}This works for me at the moment, I spent a great time implementing this as I don’t want to use state base for player which I think much more easier if I did state based. But I persist and came up with this piece of "good enough" code which works for now.
👌Note as well when building the stage or level for your game with ladders make sure you have even platform and ladder height because I got an issue before that the player fell down and got stuck into the ladder when you’re just trying to walk the top of it.