- Home /
Performance issue on iPhone 5
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<PopUpEffect> ().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?
Have you ran the profiler and looked for spikes in that frame? You should try that, first in Editor, then from device. It should tell you what's causing this.
I don't have psychical access to that iPhone 5. Profiler in Editor doesn't show any spikes on "tap". But it also was happening on collecting an item on path, so i searched for a common actions for these 2 moments - it turns out that updating UI Text component with current score/item count cause this. Now i'm about to check why is that happening - my idea for now are corrupted font file, don't know if that's possible. If that's not it, i'm gonna install newest unity - now i'm using 5.1.3. But my previous game was also built with 5.1.3 and there was no problem with updating text..
Answer by wojtask12 · Nov 03, 2015 at 08:52 PM
That was font issue - changing the font file to .otf version found in web helped.
Your answer
Follow this Question
Related Questions
iOS builds run poorly until device restarted after update 0 Answers
Game Runs Horribly Slow On iPad? 3 Answers
device.present lag iOS iPad1 0 Answers
[iOS] Frame rate drops when ASSISTIVE TOUCH is on 0 Answers
Coin Magnet Performance Issue Mobile 3 Answers