I am interested in how is organized scenes and objects in such games. There we have many permanent (possible living) objects: star systems with planets, fleet with ships, population, etc. But in same time we can enter some regions: star system, planet screen, fleet screen or open some other screens: diplomacy or ship designer.
I don’t fully understand how it is can be implemented in Unity? Especially with living world like in Stellaris. And how is created star system management screen in Endless Space and fast return to galaxy map.
It will be too slow to implement this as different scenes (and recreate whole world each time after closing another scene like diplomacy) or impossible because of the need to calculate living world while user in another scene. And it will be not so comfortable to create this scenes on the fly. And what about DontDestroyOnLoad - is it right way to keep so much objects? In this case we need each time to hide them and prevent them to interact with current local scene objects and avoid performance issues.
In general, it would be interesting to hear thoughts about the organization of scenes and global living objects in such games. Thanks.
In a big game like that, it will probably go like this:
Objects live and are processed in a sort of a database, in background. Those objects are not GameObjects. They’re classes that have very little to do with GameObjects, Components, and unity architecture.
When you visit a specific location, displayable entities for it are created upon entry to match the state of the “database”. Background planets, ships, etc.
One example of this could be X3 series. In the game the data was processed in two different ways - one way was for the sector where the player is present (real-time flight, combat, etc. Involved a lot of crashing, because X3’s pilots were horrible at collision avoidance. One good way to lose a huge ship was making it go through the gate in a sector where you were present. It would crash into the gate with very high probability). And another one was for anything that happens outside of current sector. That was pretty close to a turn-based approach, except that turns were very small. As a result, some ships have different performances in “in-sector” and “out-of-sector” modes. At least one ship was nearly useless in “in-sector”(realtime) mode when controller by ai, and could mope floor with nearly anything when it was processed in “out of sector” mode.
Basically, with this kind of situation, Unity is reduced as some sort of display framework, which only produces displayable data as necessary.
So, yeah. It is constructing scenes on the fly, most likely.
Thanks for the answers. Can anyone recommend some articles about this techniques? I fear the lack of performance and problems with GC in scenario with much loadings/unloadings of game objects.