Is it possible to pause a scene and save its state in the background while loading another scene? I have a scene where battles happen in my game and a scene where conversations take place. When the player initiates a conversation, loading thst scene, then returns from it, I would like the state of the battle scene to pick up from where it left rather than starting from scratch again.
In short to directly answer your question: no. A scene is either loaded or it isn’t. To restore the state of a scene, you will need to save the necessary data before leaving it to reconstruct it as required later on.
This effectively boils down to save game stuff, as you will also need to do the same thing to let the player save, quit, and reload the game later on. It’s definitely important to think of save games as early as possible, as you can often design yourself into a place where you have to refactor a ton of code and systems as they weren’t designed with save games in mind.
Though if you haven’t done any save game related stuff, I’d start with tutorials on that first.
Well shoot. The reason I was hoping for this was to prevent the player from abusing the scene transitions to escape from fight scenarios. I might just have to disable communications until the player can find a way to de-escalate.
All the state that needs to be saved for the game is already taken care of. Things like mid battle saves aren’t something which will be suported.
Or sounds like you will need be able to save the state of a battle, at least even temporarily (so it doesn’t need to be written to disk in that case) if you don’t intend to let the player save-scum through combat.
That’s the most advice I can give without knowing any more specifics about the type of game.
You can also achieve this by loading the conversation scene additively, and then deactivating everything in the battle scene.
That’ll be a bit harder to manage than just a hard unload of the scene, but it will mean that returning from the conversation to the battle will be faster, as all the data for your battle scene will stay in memory.
Ahh, thank you! This is exactly what I’m looking for! And my game has fairly low requirements, so this isn’t going to be taxing anyone’s systems.