I’d like to create a game that has a number of potential “spaces”, all drawn in the same place in Unity (IE without moving the camera), and to be able to swap between them, while still saving some state about these spaces. To make it less abstract, here are a few examples:
Suppose I’m making a puzzle platformer that has a “dream world” and a “real world”, and I want to switch between them, saving state in both - when I kill someone in the dream world and go to reality and back to dreams, the person remains dead.
As a more complicated example that more closely reflects what I’m trying to do, suppose there’s a roguelike or a strategy game or something that has some arbitrary number of “maps”, each of which can have any arbitrary state (player/unit positions, loot, level layout), which needs to be maintained even when that map isn’t loaded.
The first example could potentially be handled by having two cameras, or two layers, or something else. The second example is what I’d actually like to do, however. What would be the preferred, optimal way to handle this scenario, where I want to be able to get rid of meshes, colliders, and all of the other data that doesn’t directly apply to what’s being drawn at any given moment?
I’ve considered simply removing the gameobjects then re-instantiating them, but that sounds costly. Is there a better alternative?