1
\$\begingroup\$

I made a 2D infinite runner. My game was approved for iOS and now pending release. However, on Android, performance is a nightmare. So I'm tweaking to optimize performance. As it stands now, there is game scene and game over scene. On game over scene, there is "Play Again" button that reloads the game scene. Now, if instead of having separate scene, if i handle the play again in same scene, will it be better than reloading the scene? What i could do is, have initial speed, position etc stored in array for example and when play again is clicked, set all gameobjects to the initial values. Will the performance be better with this? since gameobjects are now not getting destroyed and reloaded?

\$\endgroup\$
2
\$\begingroup\$

It depends what "performance" you are attempting to optimize. "Performance" is an umbrella term that could be referring to many things. Like, if your load times are too long, then sure not loading will eliminate that wait. But if you mean how fast the game is running during gameplay, then no this makes no difference.

Or rather, it certainly won't make the game run faster. It's possible for your game to run slower after making this change, because now you aren't cleaning up everything in the scene and filling up memory. Of course, then your real problem is that you have lots of extra objects filling up your memory, and the memory wipe from loading the scene was covering up this issue.

\$\endgroup\$
  • \$\begingroup\$ yeah it was mainly about loading. There was considerable lag when scene was reloaded. I have now eliminated reloading. \$\endgroup\$ – SanSolo Aug 5 '15 at 16:56
1
\$\begingroup\$

I believe it is better to reload the scene using SceneManager.LoadScene() as this will require less code than positioning everything all over again. However it might depend a little on your scene, things like checkpoints and high scores.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.