- Home /
proceduraly generated galaxy
So i was watching "How Does No Man's Sky Actually Work? - Reality Check" and i decided to give it a shot since I have been wanting to do a giant galaxy in a game yet i dont know how to save data and im sure it would take a lot of memory. So what i was basicaly going for was not a completely proceduraly generated system but more like deciding the place to spawn a prefab and its characteristics like being able to tell the game to generate a prefab of a sun when i get somewere, maybe give that sun a particular size and color according to diferent factors like (and im no astrologist, im just guessing here) proximity to debree and gas tipe or something, also have some planets orbiting and maby have some with rings or several moons and stuff, you get my point.
so the paroach i had was to take the position and with it use calculations to tell the game where to spawn "x" prefab, but that didn`t get me anywhere.
my question to you guys is how would you go about proceduraly generating a galaxy?
thank you all, -thenachotech
What happens if the player returns to a previously visited solar system, which you have not saved from the first visit, to find that it has a different sized sun and a different amount of differently sized planets... You need to have some sort of underlying data structure in place(save or procedural parameters) that will make each solar system stay the same...
actualy if its not random and you use conditions, like say the color of a sun is based on its position, so long these conditions dont change you sould get the same sun
"Astronomer", rather..."astrologist" is something else entirely. ;)
Answer by Ricewind1 · Nov 05, 2014 at 01:18 AM
I'm no astrologist either so I'm not sure how galaxies work; but lets say each one has a sun. Start by spawning a sun and a random amount of planets around it with random distances from the sun. Do this increasingly so you can make sure 2 planets can't collide. You can then spawn moons/asteroids around the planets the same was as you did with planets and the suns, again making sure that they can't collide. You can even make moons around moons (just use a recursive method).
Next comes the spawning of multiple galaxies. Move from the first galaxy to a random x,y,z away. Making sure the distances are large enough. Then from this point start spawning again from the start and with each planet, make sure they can't collide with their sun and the other galaxies. You can easily get the range between the sun and the most outward planet to calculate this.
From here you can keep going with the current galaxy or start spawning from both suns. The last method is recursive as well.
Be careful not to have an endless loop while spawning. Also keep checking every time if planets/suns can't collide and that they are spread far enough. You can even use overlap spheres to test this if you wanted.
Lastly you can add things like asteroids or meteoroids. Spawning them at a random place that doesn't collide. Distance(Sun, Planet) + Planet.x /2 (upper collide value) Distance(Sun, Planet) - Planet.x /2 (lower collide value)
If you check that newly spawned things don't fall between those numbers you're ok.
I think you might be confusing Galaxies with Solar Systems...
A Galaxy is a collection of solar systems orbiting what is currently thought to be a super massive black hole at the galaxy center. Our galaxy has at least 100 billion to 400 billion stars in it.
A Solar system is a collection of planets that orbit a star(like our sun), or sometimes two stars(a binary system), maybe more sometimes...
So? It's still the same as I said, only different ter$$anonymous$$ology.
Thanks a lot ricewind. This has been bugging me all afternoon, finaly ill get something done.
Answer by slay_mithos · Nov 05, 2014 at 01:44 AM
Ricewind's answer is pretty good already, but I have a few points that might help.
The ways to do it mostly depends on a few things. For example, do you want the planets/moons/stars to rotate during the course of the game? Do you want the rotation to be fixed or calculated with physical laws. Do you want to respect the real world's laws (weight, distances, speed, size...)? Do you want the orbits circular? Do you want the orbits to all be polar? Is it 2D or 3D?
Having made a prototype on XNA during my last year as a student, I had to answer all of these too, and it all comes down to how much time and computing power you want to allocate to this.
If you just want to make a galaxy, you can follow the advices RiceWind gave you, and add a few things like colours for your stars and planets.
I'd suggest adding a class structure and scripts to handle rotation/speed etc. You can use these scripts for orbiting and other things too.
Answer by Kiwasi · Nov 05, 2014 at 03:06 AM
What I would be looking for is a function that can generate noise that can be converted into a galaxy. Perlin noise might do the job, with a bit of refinement. There are other pseudorandom functions that exist. The main property you are after is that if you pass a set of coordinates to the function it will always return the same result.
This way you have no need to store the actual data. You can simply query your noise function and generate the local galaxy region on the fly as the player passes through it.
To complete this you need a deterministic (ie no calls to Random) method to generate local space given a small number of parameters.
Your answer
Follow this Question
Related Questions
Procedural Generated Galaxy 2 Answers
Simple 2D procedural galaxy map 2 Answers
Procedural Cylinder Generation 2 Answers
Galaxy Procedural Generation 1 Answer
OnValidate changed fields doesnt save after exit the play mode. 1 Answer