Problems with collision callback

Hello. I’m writing a simple platformer game. I use tiled maps to create level layers for overlaps and collisions. I’m stuck with a problem: I’m trying to make player able to climb the ladder when collision happens.

I have a variable in gameSettings object playerMoveY: false (so by default player can only walk left or right)

Also I have this code in movePlayerManager method:

movePlayerManager() {
if (gameSettings.playerMoveY) {
if (this.cursorKeys.up.isDown) {
this.player.anims.play(‘playerClimb’, true);
this.player.setVelocityY(-gameSettings.playerSpeed);
} else if (this.cursorKeys.down.isDown) {
this.player.anims.play(‘playerClimb’, true);
this.player.setVelocityY(gameSettings.playerSpeed);
} else {
this.player.setVelocityY(0);
}
}

and here’s the callback function called when player overlaps a ladder tile

allowClimb() {
gameSettings.playerMoveY = true;
}

But the problem is that once the player overlapped the ladder playerMoveY is still set to true. But I want to change it back to false when player not overlaps the ladder. Can you help me?

Sorry for bothering. I found out how to make it. I just moved the part of the code from movePlayerManager (if statements for moves up and down) inside climb() method and now it works just amazing!