button and touch both active at the same time

Hi everyone

I have a game that moves the player based on input.getTouch.

I also have a button that runs the pause. both work great. the problem is that when i hit the pause button it also calls the movement method. the pause method itself is working fine (all movement is stopping) but the same problem comes up when I unpause it. it will move towards the button since its calling both function of the pause button and the movement method.

how do it set it up so that when i hit the button it doesn’t also call the movement method.

*note - the pause button is in the canvas and is controlled with a different script called UIManager

Try this in your UI button click method:

           // Check if the mouse was clicked over a UI element
            if (EventSystem.current.IsPointerOverGameObject())
                Debug.Log("Clicked on the UI");

For Touch:

          Debug.Log("Touched the UI");

awesome I will try that. does that block it from interacting with the play area or just lets me know I interacted with the UI and then I have to tell it what to do from there.