- Home /
Touch Delay / Lag in Movement only on iOS Device
Hi all,
I have a follow-up problem after my previous question. There is a lag when I build the project and run it on a physical iOS Device (iPhone X)
I have a Player (Rectangle) that moves forward automatically and gets rotated by touching the left or right side of the screen. This is the movement script:
void Update()
{
if (Input.GetMouseButton(0))
{
Vector3 touchposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (touchposition.x < 0)
{ rot = 5* Time.deltaTime / 0.02f; }
else if (touchposition.x > 0)
{ rot = -5* Time.deltaTime / 0.02f; }
transform.Rotate(0, 0, rot);
}
}
private void FixedUpdate()
{ rigidbody.velocity = 10 * transform.up ; }
It is important to know, that in this game you don't just tap. You always have to hold your finger for more than one frame.
Concrete Problem: In like 1 from 15 touches, the touch is recognised with a delay of about 2 (!) seconds. That means, that the player just moves straight forward. The delay is so big, that the player mostly hits an obstacle and dies. In those other 14 from 15 cases, there is no lag.
Once the Player reacts on a constant touch (that is I press my finger and don't let go), the rotation works normally until I let go. So there is no interruption in the touch reading process.
The most confusing part is, that most of the time there is no delay. Thats makes it really hard to identify the issue. This is what I found out so far:
No Delay when only tapped (no constant touch). A tap is ALWAYS recognised immediately.
Size of touch area is no issue. My taps get recognised even if I use only a finger nail
Delay may occur in both directions (rotating left and right)
Delay does not occur every time. Only in about 1 from 15 cases
Overlap of touches (two fingers at the same time) is no issue. The delay occurs mostly when I switch from 0 touches to 1 touch
Also: it worked perfectly smooth on an Android Device (Samsung A51). No lags.
What may be causing this issue?
Thanks in advance!