- Home /
Game State vs Multiple Levels
The answer is probably a case by case basis, but generally speaking is the general practice to use Object.DontDestroyOnLoad to carry over the same GameState object/scripts from level to level or simply write a whole new game state for each level loaded. The latter seems wrong, but wanted to take a quick poll.
Answer by Fornoreason1000 · Jan 16, 2015 at 06:40 AM
you said it your self it depends, lets say I have player with Weapon2 equipped and he/she advances(or just travels) to another area where another level needs to be loaded,
of course you want the game to remember which weapon the player had, so we can't jsut leave the prefab to initialize itself (thus having Weapon1 All of a sudden), so we either have to carry the player over using DontDestoryOnload or use a GameState ScriptableObject singleton(or any single for that matter).
UI like Health bars and menus can be re-instantiated normally, sometimes it just more efficient to use DontDestroyOnLoad then having to mess around with recreating objects. it could be considered "safer" in terms of avoiding loss of progress since you won't be reloading anything.
Thanks. That's kind of the way I was headed but wanted to hear some other feedback to make sure I wasn't going down the wrong path. Thanks!