Hi guys,
I'm getting some weird performance issues on iPhone 5 - the game lags when the user taps the screen to change direction. It doesn't happen on iPhone 6/iPod 6g/iPhone 4. Tried to experiment with disabling sounds, changing fixed timestep, but nothing helps. Here's my Update code which seems to be a problem:
void Update ()
{
if (Input.GetButtonDown ("Fire1")) {
if(started)
{
gameController.IncScore ();
if (nextLos == 0)
{
index += ballDir;
if (index == TrackPath.currentPath.angles.Length)
index = 0;
else if (index == -1)
index = TrackPath.currentPath.angles.Length - 1;
ballDir *= -1;
dir = Quaternion.Euler (0, 0, 180) * dir;
}
else
{
index += ballDir;
if (index == TrackPath.currentPath.angles.Length)
index = 0;
if (index == -1)
index = TrackPath.currentPath.angles.Length - 1;
dir = Quaternion.Euler(0, 0, TrackPath.currentPath.angles[index] * ballDir) * dir;
pathNo += ballDir;
if (pathNo == -1)
pathNo = TrackPath.currentPath.angles.Length - 1;
else if (pathNo == TrackPath.currentPath.angles.Length)
pathNo = 0;
}
}
else {
started=true;
gameController.tapToStart.GetComponent ().StartCoroutine ("SimplePopDown");
if (nextLos == 0) {
ballDir = -1;
index = 1;
dir = TrackPath.currentPath.startDir2;
} else {
ballDir = 1;
dir = TrackPath.currentPath.startDir1;
}
}
if (pathNo == 2)
tpJumpsCount++;
else {
keyCountdown--;
if (keyCountdown == 0) {
gameController.SpawnKey ();
keyCountdown = keyDelay;
}
}
nextLos = next2Los;
next2Los = Random.Range (0, 4);
if (v < 7f)
v += .2f;
player.velocity = dir*v;
}
}
void IncScore() is just `score++; ScoreView.text=score+"";`
What's interesting, the longer the game is running, the smoother it gets - after couple minutes running it's perfect. It also seems to run a little better on iPhone 5 with ios 9 - lags on tap are not that often - but still happens. On ihone 5 with ios 8 - the lag happens almost each time you hit a screen.
Can you see anything suspicious? Or you had similar problem with iPhone 5?
↧