- Home /
Touch are laggy on ipod touch(4th gen.)
Hi. I am currently using gameObjects for user interface in my game. The are childed to main camera and i use this code for detecting touches.
function Update() { if(Input.touchCount > 0) { for (var i = 0; i < Input.touchCount; ++i) {
var xTouch : Touch = Input.GetTouch(i);
var xRay : Ray = Camera.main.ScreenPointToRay (xTouch.position);
var xHit : RaycastHit ;
if(Physics.Raycast (xRay, xHit, 25) )
{
if(xHit.collider.tag == "bLeft" && !isPaused)
{
rotLeft = true ;
rotRight = false;
}
// and there is more but same as above
}
}
This worked for me until some of new level in my game touches are very laggy on my iPod Touch(4th gen.) Booth with unity remote and builded version. Should i use guitexture for user interface or this lag occur because of something else. By the way laggy level has only 8-10 draw calls, other levels has 20-25 draw calls.
I have figure it out. I have ground sprite and collider on it. It's strange, I was scaled them and made bigger to reduce draw calls; after that touch-lag problem occurs.And now i scaled them back the problem gone.
generally keep an eye on your CPU usage. the iPod4 works fine but it can run really slow if CPU gets too high