Hello guys, I’ve got a problem with touch functions in unity.
i’ve got this code for the movement of the player inside the update function (when the touch begins, it works):
if((Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) && !paused){
rb.velocity = Vector3.zero;
rb.AddForce(UpForce, 0, 0);
lerpingStarted = false;
}
Everytime i want to click the pause button in my game (it is a simple button inside a canvas, attached to it there is a script that change the variable “paused” to true if the button is clicked while not in pause), the game, before it pauses, detect the touch (or the mouse click) and makes the player move. I want to avoid this.
My goal is to not let the game detects the touch if i click the pause button. I tried to use raycast attaching a collider to the button, but the result was the same. What can i do?
Thank you in advance.