I created a system which spawns a galaxy based on a random seed (everything depends on it, the star type, the number of planets and their size and number of moons and sizes each planet has). I want to save the world and I’m wondering whether I should save the galaxy itself or maybe the seed and get it generated each time, and how I can do so.
Also, I got set that if a celestial body size is 0, it gets destroyed. However, it still appears on my hierarchy. How is that so?
I have no idea why the objects still show up in your hierarchy but saving by seed sounds to be a smart idea. And it must be rather simple to implement as you just need to keep your seed and saving it on demand. When loading it back into you scene, you just need to apply the initial galaxy creation code again. Just like a usual import/exporter works.
A lot depends on your loading requirements. If you load the galaxy once at the start of the game then storing seed only is fine. But if you want to do some more dynamic loading / creation then you will need some more data saved.
Also, how can I set an object as child of another object in the runtime? I.E: In the system generation it instantiates a sun in the center of the system, which I want to be children of the system. The sun Start() instantiates the planets, Which I want to be the sun’s children. Any ideas?