- Home /
Too subjective and argumentative
What is the best way to deal with game state and changing levels?
I am a professional programmer but new to game development and Unity. I am working on a simple arcade game where currently I have a single scene which will be used for all my game levels (levels differs only on how/what enemies are spawned). Currently I only have the 1st level and I need to decide how to deal with level changes, game state and main menu. Therefore I have a couple of question:
When changing level should I use SceneManager to reload the scene or write some custom script to remove all spawned game objects and reset level?
How to deal with game state? I have seen a couple of approaches: normal c# singletone (https://www.packtpub.com/books/content/creating-simple-gamemanager-using-unity3d), unity specific singleton (http://clearcutgames.net/home/?p=437), preload scene (https://stackoverflow.com/questions/35890932/unity-game-manager-script-works-only-one-time/35891919#35891919) but I don't know which is considered as best practice.
Should main menu be a separate scene or it's better to build GUI on the top of my single scene?
When having multiple scenes and singletons using DontDestroyOnLoad how to deal with testing individual scenes? Each scene should have the objects added or there is some way to load them form the first scene even if I want to check some other?
Thank you in advance.
Best regards Lukasz, I am a professional programmer but new to game development and Unity. I am working on a simple arcade game where currently I have a single scene which will be used for all my game levels (levels differs only on how/what enemies are spawned). Currently I only have the 1st level and I need to decide how to deal with level changes, game state and main menu. Therefore I have a couple of question:
When changing level should I use SceneManager to reload the scene or write some custom script to remove all spawned game objects and reset level?
How to deal with game state? I have seen a couple of approaches: normal c# singletone (https://www.packtpub.com/books/content/creating-simple-gamemanager-using-unity3d), unity specific singleton (http://clearcutgames.net/home/?p=437), preload scene (https://stackoverflow.com/questions/35890932/unity-game-manager-script-works-only-one-time/35891919#35891919) but I don't know which is considered as best practice.
Should main menu be a separate scene or it's better to build GUI on the top of my single scene?
When having multiple scenes and singletons using DontDestroyOnLoad how to deal with testing individual scenes? Each scene should have the objects added or there is some way to load them form the first scene even if I want to check some other?
Thank you in advance.
Best regards Lukasz
Hi Lukasz, sorry your question is regarded as "Off-topic, subjective or argumentative" due to its nature of requiring discussion. "Best practise" is a grey area, but the best way to learn how the devs think it should be done is to breeze through the tutorial content. It should be quick as a programmer. Dont let this put you off posting. But in future, ask 1 question at a time and try to be a bit more specific.
Also, discussions can be posted on the Forums, nearly forgot to mention.
Follow this Question
Related Questions
Best practice for object communication 3 Answers
Which to use Arrays, Collections, Lists and Generics 0 Answers
Best Practices for exception handling Resource.Load 1 Answer
Propogate upgrade to different entities (Wepon upgrade System) 1 Answer
What is the best practice in handling scenes with 100+ rigidbodies and collisions on iOS? 1 Answer