- Home /
iOS Lag From Updating Score
I'm working on a 2D platformer where the score is based on the distance traveled by the player. I originally used the update routine to check the player's position and update the uGUI textbox, but I had to make some changes because it caused some substantial lag on all platforms. With these changes, the game now runs fairly smoothly on Android, but it still causes a lot of framerate issues in iOS. I'm having trouble thinking of how to simplify my script further, other than choosing to update every 5 points instead of every point, which is an option I would rather not consider. Can anyone with experience solving this issue give me some advice on how to more efficiently keep the score updated? Here is the script I am currently using:
IEnumerator UpdateScore()
{
while( true )
{
if( _isPlaying )
{
_score = (int)player.position.x;
scoreText.text = _score.ToString();
}
yield return new WaitForSeconds( 0.25f );
}
}
As you can see, I'm using a coroutine to update the score every 1/4 second, since the player's rigidbody moves at a velocity of 4 m/s.
Your answer
Follow this Question
Related Questions
Sprite movement is jittery/laggy 1 Answer
Linecast not returning distance 2 Answers
Multiplayer Clients Jitter On Moving Platform? 1 Answer
facing lag/jitter issues in multiplayer game. 1 Answer
Game "laggy" at 30FPS smooth on 60 2 Answers