Procedural galaxy doubts.

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?

Thanks in advance!

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.

Nothing is destroyed unless you use Destroy. Simply setting an object’s scale only changes its apparent size.

–Eric

I know, that’s Why I said that I got set to destroy with Destroy(GameObject) after an if statement. It still appears on my hierarchy.

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?

That means it wasn’t destroyed, so you need to take another look at your logic.

–Eric

Use Transform.parent. Just set one transform to be the parent of the other transform and it will show up in the hierarchy as the child.

http://docs.unity3d.com/ScriptReference/Transform-parent.html