Hello. Now I’m doing a simple Flappy Bird-like game, which has a simple PlayerController class like this:
if (Input.GetMouseButtonDown (0) || Input.GetButtonDown (“Jump”)) {
// Player flying up code
}
I also add a pause button. In the Button component, I hook a pause function with On Click (). Everything works fine, except when I play the game and press the pause button, player also flies up.
What is a good way to cancel player input when pressing a pause button? Thank you.
You could put a public bool in your player controls and set it to true when the mouse is over the pause button and false when it leaves using OnMouseEnter and OnMouseExit.
If the bool is true in the player control then ignore inputs.