Hello. I have a world map scene with a lot of npcs on it that interact with eachother. The player can enter a village on the world map, which loads a new scene. I need the world map to stay in memory so the npcs can keep interacting with each other, even when the player is in a different level. Is there a way to keep a level loaded in memory, but make it “invisible” so that I can have the player in one scene that is loaded and being displayed, but still have the world map fully loaded but invisible? Thanks.
Have you considered using Application.LoadLevelAdditive (or the async version if you have PRO) to load your village scene? This would prevent your world map scene from being destroyed.
But wouldn’t Application.LoadLevelAdditive keep the world map visible if I loaded my village? I basically want to have the world map always be loaded(all the npc objects) but have it be invisible when the player enters a village.
If you want to keep only the NPC objects from the world map, then consider setting DontDestroyOnLoad on them.
I had considered this, but then wouldn’t the npcs be rendered in the new map that is loaded? And I think I would still need the world map MAP to be loaded so I have access to what tiles are walkable etc.
It sounds like what you want is your levels to run as a simulation when the user can’t see them i.e. when they are on the world map you have described. Unity can’t allow you to do this via its Scene loading api. If you treated a level like a prefab instead of a scene then you could get what you are looking for. You could set up multiple cameras in a single scene and instantiate levels as prefabs. Naturally, if you have a lot of levels then you might run into some performance issues. If this is the case then you might want to consider faking it. You could run a function that effectively runs a simulation as a function call on entering a level that you have been to before. This function would “fast forward” your level simulation so it makes sense before you go to render it. Another option, a much more elaborate one, would be to have the levels simulated on a server and when ever you enter a level on your unity client it updates from the server simulation that could always be running.
Thanks for the great idea guywhosignedup. That is an interesting idea. But if I have 1 world map loaded, and then the player goes to a village, and I load the village as a prefab “level”, why would it be resource intensive if the player is only in 1 other level besides the world map? Then you can just unload the other prefab villages and only load them when the player enters them. I feel like that idea might actually work. Then I won;t have to create a fake system to simulate what is happening in the unloaded world map when the player is just sitting in a village for 10 hours.