- Home /
How do i get rid of touch lag between touch ending on device and action in game? Or is it possible, on Unity Remote 4 using Nexus 7 2012 with if (Input.touchCount > 0) for touch input?
Having struggled with touch input in games and testing games on an android device i have been using using unity remote 4 on a Nexus 7 2012 (1st Gen) and to master touch input i have been using if (Input.touchCount > 0)
on a UI Button which seems to solve my problem as whenever i touch the screen Input.touchCount
equals 1 and that works, my code is below;
public class Left : MonoBehaviour {
GameObject car;
int speed = 100;
// Use this for initialization
void Start ()
{
car = GameObject.Find("Car");
}
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)
{
car.transform.Rotate(Vector3.up * Time.deltaTime * speed);
Debug.Log("LEFT");
}
}
}
It is very simple code which is easy for me than confusing event managers or other ways to do touch input. But the problem is when I release touch on the button which this code is attached to, both the car rotation and debug logging of "LEFT" continues for a short period, at least one second which could be catastrophic for me when i create simple games focused on reaction.
Thank you for reading my question, I would hope their is a solution to avoid the lag or I can blame it on my old device and unity remote, meaning it would work if i actually released it. Opinions or answers would be much thanked!
I tried get rid of speed
by changing Vector3.up
to new Vector3 (0,25,0)
as i thought speed may prolong the rotation but a larger vector 3 may still increase the rotation
If this is just how it is, having struggled to find decent guidance on testing apps through android studio, could someone direct me to information on how to test my apps, I guess through android studio. Thanks,
Answer by g__l · Aug 04, 2016 at 02:07 PM
[I later discovered] Unity Remote 4 will never be perfect as it is not the app itself, hence the code doesn't matter. In order to test an app i recommend building an apk of your app, placing it on your mobile device, and then, by use of a file explorer app, opening and installing it manually for no lag (unless of course the code is very demanding).