Resetting input axes values and not the button press

Hi, I’m trying to implement a wall jump feature in my game where the Player is allowed to slide down slowly on the walls and can still jump whenever.

I had to reset the input axes because if I don’t, the player will stick back immediately on the wall right after the player attempts to jump while sliding because the velocity of the player depends on how long the button is pressed and it is at its maximum value when sliding on the wall so I have to reset the input axes like this:

// WALL JUMPING
if (isWallSliding && (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.X))){
//Reset Velocity after Jump
Input.ResetInputAxes();
rigidbody2D.velocity = new Vector2(0, 0); 

//Apply Jump Force
if (isFacingRight){
  rigidbody2D.AddForce(new Vector2(-wallJumpDistance, wallJumpForce));
} else if (!isFacingRight){
     rigidbody2D.AddForce(new Vector2(wallJumpDistance, wallJumpForce));
  }
}

But if I use “Input.ResetInputAxes();” and the player is still holding the horizontal button, it resets the horizontal values AND acts as if the player also released the button.

Visual Representation:

As you can see here, If I press jump and I’m still holding the left button, the player will jump straight on the right wall as if I already released the left button.

What I want is this, it will push the player for a certain distance but if I’m still holding the left button, it will act as if I only bounced from the wall.

33326-problem2.jpg

How will I reset only the values and not the button press? Any fix to that?

I just realized that there is no way to change the values of the input axes so using Input.ResetInputAxes() will reset both the button press and the values even if the player is still holding down the button.

The only way to solve this is to wrap all the input processes into a custom method/function which will override the default input processing… This is quite complicated for me to implement at the moment so I’ll leave my game like that.