Having an issue with touch input lag on certain Android devices, any help?
Hi. I recently released an app on the playstore: https://play.google.com/store/apps/details?id=com.mparl.simonsaysjump
I have tested it on a few mid-range devices with no problems such as an LG G4 and a Moto G5.
When testing on higher end devices, I have mixed results. Seems to be fine on a Galaxy Note 8 but has a touch input lag of around 0.2 seconds on a OnePlus 5.
I am sure this is the touch input lagging and not the entire game as there is an option for tilt controls which work without delay on the OnePlus 5.
When doing some research into the issue it seems to be a problem with using Unity for Android and I could not find a fix: https://forum.unity.com/threads/touch-input-lag-other-games-are-fine.239253/
I was wondering if anyone has experienced similar problems, or has a solution? (If you need more information about the problem please just ask)
I have also run out of housemates whose phones I can test on, so If anyone has the time to run the app on their device (especially if it is a OnePlus 5) and let me know if there's any input lag that would be very helpful.
Answer by Michael_Starmik · May 21 at 10:44 AM
Hi! I am having similar issue. I have a problem with Android input lag on my OnePlus 7T with this code:
if (Input.GetMouseButtonDown(0))
{
if (EventSystem.current.IsPointerOverGameObject())
{
Debug.Log("Hit UI, returning");
return;
}
Debug.Log("Checked for UI");
Vector2 origin = new Vector2(Camera.main.ScreenToWorldPoint(fp).x,
Camera.main.ScreenToWorldPoint(fp).y);
RaycastHit2D hit = Physics2D.Raycast(origin, transform.forward, 0);
Debug.DrawRay(origin, transform.forward, Color.yellow, 50f);
Debug.Log("Fire raycast");
if (hit)
{
Debug.Log(hit.transform.gameObject.name);
}
}
For some reason, testing in Unity editor works fine, but when testing through my phone, it all gets one step behind for some reason: First tap on game object fine, then when I tap the UI element I get return as if tapping game object, then after taping on game object I get debug.log reaction from collision with UI and so on...
I think this might be related to your problem. Did you find any solution?
EDIT: I have tested both connection through Unity Remote 5, that's when lagging occurs
But when installing the app to the phone directly, tapping anywhere launches the action regardless of whether it is obscured by UI or not...
Why are the controls behaving differently?