TL;DR: If you wanted to make a game where you have a main scene in which every change should be saved and then also a secondary scene where you don’t care about changes and the player should be allowed to travel freely between the two scenes, how would you approach it? Would you load the secondary scene additively on top of the main scene or would you treat it in much the same way you would a save system? Or would you do something completely different?
I put RPG in the title because I believe that makes this easier to explain. And I know RPG’s are populare with noob developers such as myself. ![]()
What I have at the moment is one scene with a town where my player starts. In this scene he should be able to receive quests, trade with vendors and most importantly anything he changes, items he puts on the ground or whatever else he does here should be saved throughout the game. In addition to the town scene I also have a scene with a dungeon which is generated randomly every time the scene is loaded. The idea is for the player to go into the dungeon, slay the monsters and then return to the town to sell etc. and then load a new random dungeon, rinse and repeat. Think any Diablo game or Diablo clone.
But how do you approach something like this? Currently I have very little experience with games spanning multiple scenes and maybe this doesn’t have to involve multiple scenes at all? I don’t know yet.
I’ve gotten the basics down so far. When the game starts my player spawns into my main scene and my player and everything connected to him is marked as DontDestroyOnLoad so it persists when I go back and fourth between my dungeon scene and my town scene. His inventory, his stats and everything he picks up or changes about himself persists the way I want it to. But the town scene is loaded fresh every time the player returns to it so all vendor inventories are reset, any items on the ground are gone etc. etc.
Currently I have two different alternatives in mind for approaching this:
Alternative A) I’ve noticed I can load scenes additively. But then I need to manually take care of hiding everything in the town scene when the dungeon scene is loaded, and any scene specific settings like scene lighting are not loaded from the dungeon scene, so I guess I need to create a system to handle those as well? And this approach feels wrong to me. To me loading scenes additively feels like something you use for a large streaming world or as a way of loading complex prefabs, like in a roguelike for loading new rooms as you walk through the level. Not something you’d use when you actually want to replace your current scene like I do. And I don’t like the idea of having thousands of game objects (my town) just hanging around deactivated while I’m in my dungeon. Not sure if this would be a performance problem or not, but I just don’t like the idea of it. ![]()
Alternative B) Another alternative is handling it in much the same way you would a save system, I guess (I have never written one of those either so I don’t know :p). Basically I’m thinking that when I load the dungeon scene and destroy the town scene I save everything that has changed and then when the town scene is created again I add back all those changes. I have to create a save system sooner or later to be able to save my game between play sessions so I would have to tackle such a system no matter what. I’ve been thinking about how other games, Unity or otherwise, handles this and reusing the save system seems very logical to me. For the player there is no difference whether he puts some items on the ground and quits the game or whether he enters the dungeon and returns to the town, he expects those same items to be there on the ground in either scenario. Which is why I’m thinking you would use basically the exact same system for both of these things.
What do you think? Any other ways to approach this? And are there any guides/tutorials/articles/projects on the topic that you can point me to? I’ve googled quite a bit, but I haven’t found anything yet.
Note: Almost every Diablo game and clone is multiplayer and I will probably try to add multiplayer to this game at some point as well, but that’s not a priority at the moment. I’m sure having multiplayer means I need to handle things in a specific way, but I won’t worry about that at this time, I just hope to hear about some different approaches towards accomplishing something like this.