The player moves whenever I touch the screen in my game. The issue is that when I press the “Pause” button, the player moves for as long as I hold down the button before releasing.
How can I make the touch input only count for a certain range of the screen? I have read about raycast but I’ve got no clue how to implement it in my game.
void Update() {
if (Input.GetMouseButton(0) && Time.timeScale != 0) {
rb.velocity = new Vector2(moveSpeed, moveSpeed);
transform.rotation = Quaternion.Euler(0, 0, -42);
} else {
rb.velocity = new Vector2(-moveSpeed, moveSpeed);
transform.rotation = Quaternion.Euler(0, 0, 42);
}
Thank you in advance!