Detect if player wants to pause or to jump

hi i’m making a mobiel game and every time the player taps the screen the player jump.that’s cool but i dont want him to jump when the player presses the pause button.i searched for a solution and didn’t find one.
ps:i cant check if the player presses a UI elemnt because of the background:if covers the whole screen.
if there anyway i can check if player presses a button or i can check the tag or the layer of the UI element.

there is two approaches i can give you.

  1. as mentioned above create a invisible button that behind pause menu. the reason for the delay on button click is the function will trigger when you left the fingure. so remove button component for that button object, and an event trigger i.e onpointer down.
    for more info

in all you need only on pointer down only.

  1. the simplest way is restricting touch to be pressed there.

i mean

void Update(){
        if (Input.GetMouseButtonDown(0))
        {
           var mousePos =  
                     Camera.main.ScreenToViewportPoint(Input.mousePosition);
            // assume your pause button is right top corner
            if(mousePos.x < 0.8 && mousePos.y > 0.2){
                          //jump();
            }
         }
}

You can try by checking if the player is tapping and the tap position is inside a limit position in x and y. Im considering that you have your UI buttons in a corner, if that’s so, it may work.

What I did for a similar game was adding an invisible button (which will act as your main screen) BEHIND the pause button and which when clicked, does the jump action so you would need to change your scripts a bit but it surely works.