- Home /
2d Solar System procedural generation
I have made a 2d solar system generator. Planets get created with random size and color, then rotate around the sun with a speed depending on their scale, the suns scale, and the distance away from the sun.
However, I have no way to save this. There are WAY too many variables. Could I use a seed to create it? I need to keep track of the position, scale and color of the planets, and the position of your ship and AI ships. I'm not sure how to save all this data. How would I do this? I'm planning on remaking this, so any solutions are appreciated.
Answer by Adarn · Sep 19, 2016 at 04:39 AM
Yes you can define the seed of an RNG. If you are useing Unity's RNG you can do it with the following public static void InitState(int seed);
https://docs.unity3d.com/ScriptReference/Random.InitState.html
Keep in mind that this will need to be done at the beginning of your game. Not at the save point. So that you know what your seed was.
Also you will most likely not be able to regenerate everything, as in order to do this you would need to run through every RNG call that you have made in the correct sequence when loading your saved state.
You will still need to save some values such as player position as their position is not determined by the RNG but the players input.
So yes you can seed the RNG to regenerate the same numbers, but you may need to implement a mix of both regeneration and saved values to save and restore your game state.
How big is your save state? Have you checked? or are you just going by what you think is a lot?