Hello there!
I just started a project for school, it’s a platformer with some basic melee combat and some exploration.
I plan to create big levels, so my first idea was to put everything in a single Scene, but then I came across Unity’s 2D Game Kit (https://assetstore.unity.com/packages/essentials/tutorial-projects/2d-game-kit-107098 this one in case you are not familiar with it) and noticed that they divide their level into zones, each zone on a different scene, so it made wonder… if putting everything in a single big scene seems much easier and simpler, why would anybody go with this option? what would they gain by adding the complexity of having to pass data between scenes?
In other words, what is the advantage of having multiple scenes for a level? I don’t know, maybe I’m missing the big picture here, although I’m not new to unity, I haven’t worked on a big project yet, so maybe if someone has more experience maybe could enlighten me a bit.
I hope I made myself clear, and thank you!
One advantage is in not having to process excess data.
Now Unity does a pretty good job of automatic culling, but it can only do so much. Go big enough and you start to find that the game starts to slow down as objects off screen still need to be processed, even if minimally. Dividing by scene eliminates that issue as you have completely removed the objects from memory. Get particularly big and you can even start to run into memory issues as the data structures can only go so big.
Now, technically speaking, you could still do everything in a single scene and get the multi scene benefit, but it means you would need to code your own routines to add and remove objects that you know don’t need further processing. Breaking it up by scene just lets Unity do more of that work instead of you, although if you want really smooth transitions you might go that route. My game, for instance, is a continuous world so I pretty much have to keep everything in one scene.
Another advantage is just simplification. Say your game has indoor and outdoor components. Trying to manage both in the same scene is a bit annoying as you constantly have to turn on that tilemap, and turn off the other one, and so forth. If you want to play test the area you also can’t instantly jump into the scene at the right point. So there is a lot of convenience to dividing by scene.
I should also note, passing data between scenes is easy, and you’ll probably end up doing it anyway if you want any kind of save system. Basically all you do is create a static object and toss all your in between data into it. This makes it easy to save as you can use any number of routines like JSON to convert that object into something savable. So that really isn’t a substantial complication. Thinking as a software engineer, it is also probably wise to do this as you may want to take the core of your game and update the engine or UI or the like. Say you wanted to go to 2D to 3D. By keeping the core data detached, it is easy to remove and put into a 3D interface, but if you keep in jumbled up with your 2D interface that is a major pain.
@Derekloffin explained pretty well the pros and cons of 1 scene vs many scenes
Doing many scenes is easy, but the game may be “worse”
I always hated worlds that are divided by “teleport points”, it always sat wrong with me that the game fades out and fades back in when I go inside a building( and the house is much bigger inside than it was looking from the outside ( happens in every single rpg ever)). The first game I saw this done correctly was in world of warcraft where the buildings were the same size from outside and from inside, and you didnt have to go through a warp to enter any zone (except instances or long travel).
It always sat wrong with me while playing zelda that the world was divided in screens and just to move to the next screen there was a transition, it gives me a feeling that the world is disconnected and whatever is in one part of the map will never cross with what is in the other it feels like a disconnected world.
For me I feel that it is worth it to go through the extra trouble of loading and unloading assets while you are far away just so you can keep everything in one scene, and the bonus is that if you ever want info that was supposed to only exist in another scene then you already have access to it with that system
To piggy back off of the others, it may have its advantages if you do many-little scenes instead of a big one. Like if you want enemies to respawn every time, it would be easier to just transition to a new scene than have a script that controls the respawning. Now, im splitting hairs a bit since that isnt difficult either but hopefully you understand.
Essentially, it depends on how you want your game to function. Some games like Zelda make sense to chunk it out as every little screen is its own puzzle and if you want to restart you just leave it and re-enter. The others talk about the performance side of it which is very important but there are also design aspects to it as well.
Thank you for your responses
I can see clearer now, multiple scenes could be the way to go in my case. I agree that it might break immersion, but well, probably I will have to settle with this for now. Maybe for my next project, I could come up with a fancy script that loads and unloads objects as I need them in one big scene.
For now, multiple scenes it is.
Thanks again!