Ladder jumping

Hey guys! Is there any way to implement a jump mechanic when climbing a ladder? What I mean is, when I press jump, the player will get off the ladder. Any kind of help will be appreciated.

Here’s the script for your reference:

void Update()
     {
         // Check if player is on ladder
         onLadder = Physics2D.OverlapCircle(transform.position, CheckRadius, LadderLayer);
 
         // Set the input values
         horizontalInput = Input.GetAxisRaw("Horizontal") * currentSpeed;
         verticalInput = Input.GetAxisRaw("Vertical") * currentSpeed;
     }
 
 void FixedUpdate()
     {
         // If player is on the ladder
         if (onLadder)
         {
             // Set the gravity scale to zero and move vertically
             playerRB.gravityScale = 0;
             playerRB.velocity = new Vector2(playerRB.velocity.x, verticalInput);
 
             playerAnimator.SetBool("onLadder", true);
         }
         else
         {
             // Reset the gravityScale value
             playerRB.gravityScale = currentGravityScale;
 
             playerAnimator.SetBool("onLadder", false);
         }
     }

Hello.

As you are using a bool variable “OnLadder” to detect that, you can just make it false when press jump button, or you can descativate the ladder collider (i supose you use colider to detect the lader) during 1 second or something like this