Touchscreen not responsive - clicking on mobile screen not working properly

Hi :smile:

i am developing a simple 2D Top Car racing game ( Open map )
The controls are simple ( when i click on right screen the car turn right / when i click left ==> car turn left)

i was going to set it using input.GetTouch , but than chosed Input.GetMouseButton(0)

if (Input.GetMouseButton(0))
        {

            if (Input.mousePosition.x > (float)Screen.width * 0.5f)
                MoveRight();

            else MoveLeft();

        }
        else StraightMovement();

when i make just 1 click at a time, all is perfect.
but when i click for example left side (when i am already clicking right) and than i remove my right finger ==> i expect the car to turn left ( wich doesn’t happen ) ==> so i have to release left click and Left click again.
This makes the Control unresponsive sometimes !!

does anyone have any solution for a responsive Touch controlling system.

Thanks in advance

Your best solution for a responsive touch controlled system is to actually use touch controls. I’m not sure why you decided not to use the touches api, but that’s what you need to use if you want control over multitouch behaviour.

1 Like

Your code does only take the input into account that is mapped to the index 0, that’s usually a specific mouse button (left by default).
You should not use the mouse API for touch. Reason being that it’s a tiny but important difference in semantics when you check for a specific button that normally keeps its index, vs checking for an input that can change its index, and only maps to an index based on the current input count.

In order to understand the difference, compare the official documentation:

The documentation of GetMouseButton states:

whereas the documentation of GetTouch says:

Additionally it says, that you can consistenly identify a touch input as long as it exists using its finger id:

So, the best advice is not to use a undocumented and partially working ā€œhack-aroundā€, because you never know how GetMouseButton(index) maps to the indexed touch input, and you never have all the information available for your gestures. Instead, use the touch API exposed by the engine and use the indeces and finger-ids in order to properly track specific touches / gestures.

2 Likes