About touch input in different screen sizes

Hello everyone, I am currently working in a mobile game. Everything was coming along nicely, but when I hit the testing phase I discovered a problem.

Ok, here is how it goes, if you touch the left side of the screen you go left, if you touch the right side of the screen you go right, pretty simple stuff. I tested this on tablets and it works perfectly, however when I deployed it on cell phones or devices with small screens the movement seems to be buggy, what I mean here is that if I use touchphase stationary on tablets it will work fine, but when I use the same on phones then it appears that it is detecting multitapping rather than a single stationary tap. Is anyone else having a similar issue? if so, how did you get it to work properly.

foreach (Touch touch in Input.touches)
        {

            if (touch.phase == TouchPhase.Stationary && touch.position.x > Screen.width/2 && Input.touchCount < 2)
            {
                move = 1;
                myTransform.Translate(Vector2.right * speed * Time.deltaTime);
                anim.SetFloat("Speed", Mathf.Abs(move));
                //facingRight = true;
            }
            else if (touch.phase == TouchPhase.Stationary && touch.position.x < Screen.width/2 && Input.touchCount < 2)
            {
                move = -1;
                myTransform.Translate(Vector2.right * speed  * Time.deltaTime);
                anim.SetFloat("Speed", Mathf.Abs(move));
                //facingRight = false;
            }
            else
            {
                move = 0;
            }
        }

Again, this works perfect on tablets, but does not work as expected on phones.

You assume that your script ends up in the else section on a phone, right? There could be two reasons for this: either touchCount is 2 or greater OR TouchPhase is not Stationary. Since the display of a phone is significantly smaller it might be that you are not able to keep your finger motionless enough to trigger the Stationary event. Actually there is a third possibility in that you do not test for the case

touch.position.x == Screen.width/2

but it is not very likely that this is your issue :wink: Anyway, for the sake of correctness, change the

touch.position.x < Screen.width/2

to

touch.position.x <= Screen.width/2