Should stages be separated by multiple scenes or code?
Hello everyone.
I have a simple requisition regarding design. If I were making a game with a large amount of stages or levels (Let's say between 30 and 50), is it better to have them all be different scenes, or to separate using code (if stage_int == 24, etc). Possibly some combination?
Just looking for a general consensus. Thanks very much.
Answer by Zodiarc · Nov 20, 2017 at 07:34 AM
You can write your own scene manager but it will be hell to find errors if you make any. I'd suggest to simply use a different scene for each stage. That way you can concentrate on making sure everything works alright in that one stage without affecting the rest.
Thanks a lot! Will the changes of scenes lose optimization, or do you think it is better than sorting through a ton of conditions for how the level will go?
Ins$$anonymous$$d of sorting thorugh a ton of conditions, use a Finite State $$anonymous$$achine It makes the management easier
Answer by Owen-Reynolds · Nov 20, 2017 at 08:38 PM
My feeling is that simple scenes -- each has it's own script running it -- is easy for beginners. Esp. if the game only goes forward. As you get more stuff that carries between scenes (what the player is carrying, which traps were spring) it's more of a pain. Often easier to code the tear-down and set-up of the new level yourself, all in one scene. Of course, instead of IFs you'd mostly have arrays with data for each scene.
The "new " load-asynch option is probably the best mix, but a little tricky. A base scene shared by a stages comes first. The player, the scoring GUI, inventory .. . Then for each stage anything you want to hand-place goes in a stage-scene. You ADD that to the base scene, then remove when leaving.
Thanks a lot! I'll have to look up the "new" load-asynch option.
Answer by Mentoliptus · Nov 21, 2017 at 07:17 AM
I would say that it depends on the type of game you are making. If it is a platformer or puzzle game or a similar game with levels that are not connected, then it is would be easier to make each level in its own scene. If you are making a level where you go back and forth between levels (scenes) then it could be tricky to tear down and recreate each level based on the game state, and then it solution with adding scenes as @Owen-Reynolds suggested seems the optimal thing to do.
Thanks a lot! Yea, it seems like doing separate scenes is the way to go.
Your answer
![](https://koobas.hobune.stream/wayback/20220612143049im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Manage Objects Common for Multiple Levels? 2 Answers
How to passing levels automatically in games? 0 Answers
Cannot access LevelChanger to change level from the pan/delay coroutine in CameraPanForIntro 0 Answers
How to have a Next Level and Game Over pop up in scene please help! 1 Answer
Communicate between scenes with prefabs? 3 Answers