I assume this is the correct forum, as a mechanism like this is mainly scripted. I’m new to Unity, I have a background working with Blitz Basic and C++.
For some years now, I have been very interested in this topic, and I’ve gone about reading what articles I stumble upon, but I still haven’t begun (minus some unsuccessful attempts in Blitz Basic which I’m going to completely ignore for now). I’m not sure where to begin, I think that the first stage would be to create a galaxy of stars represented by points or spheres, and then work myself from there to greater levels of detail, all the way to planet surfaces.
I know I’m asking a huge question, but a shove in the right direction might help, and would be greatly appreciated.
this is really a huge topic especially for a “beginner”. there is a package called etherea1 in the assetstore which creates procedura planets with adjustable detail (ie land on it). have a look at his youtube channel : http://www.youtube.com/user/xatovski
afaik he works on a galaxy wide game but progress seems to be slow. also his original package is not very well supported (no dx 11, no more updates etc). but this could give you a start.
on the other hand there are many papers regarding this out there not especially for unity but you could try to adapt the algorithms.
some considerations from my thoughts/research about this topic. use different units for different sizes. fe the position of a star is measured in light years relative to galxy center, positions of planets in astronomical uints relative to their star, and planets in meters relative to their center. different propulsion systems should be used to travel each. fe wormholes/jumpdrive between stars, warp in a system and sublight in orbits etc. this way you can “switch” between start and end without hassling what is inbetween.
you should create the galaxy dynamically from a seed. so have a seed for it which creates stars in different sectors and randomly assign them a seed for creating their planets.
use histograms to influence the probabilities of everything. fe dwarf stars make the majority of the milky way population and giant stars are quite rare.
in my opinion such “open world” games are not very thrilling as the algorithm always produces similar (realistic) patterns. and planet surfaces are not real “content” in my opinion more of decor. and with this you will also need a system which creates and distributes questst, factions, loot etc… so it is not trivial.
but again there is many stuff written about that in i don’t feel like repeating it here or searching the links for you. make a research without focus on unity.
I wouldn’t just jump in and try to code something like that if you’re starting out. It could be a lot more work than you think. First, I have to assume you’re not going for literally the number of stars in a galaxy. You’re not going to be creating 100 billion of anything. In any case, you should try learning the basics first.
Your first stop should be the Space Graphics Toolkit on the asset store. It has a script for generating starfields with tons of options. One of them is “Elliptical Galaxy” distribution. It comes with an example scene with a 30,000 star galaxy. There are also examples of how to generate procedural star systems.
It has a fancy feature where as you approach a planet, you can increase the detail, to the point where you can land on planets with full terrain.
It’s got a ton of other stuff, but the point is that it includes the C# code, so it’d be a fantastic way to study how all of that stuff was done (assuming you would need to extend the functionality).
Another space-related asset is SPACE for Unity, which has several features too, mainly a way to render colorful nebulae dynamically for tons of variety.
Yeah, from a gameplay perspective, I don’t get the desire to build a super massive world like that. Even if you could fill it all with compelling gameplay (you can’t), nobody would have time to play it. Reminds me of the old game Daggerfall that had like a continent sized play area with 15,000 towns, almost all of which were cookie-cutter and boring. Or even the original Mass Effect, that had some planets you could land on and drive around on the terrain, but each planet was almost featureless and had like the same three buildings.
a moon belongs to a planet
a planet belongs to a solar system
a solar system belongs to a galaxy
a galaxy belongs to a universe
sounds like a hierarchy of parented objects to me… and when you’re looking at a whole galaxy, you’re not going to need to know anything about the moons or planets, you’re just going to see the solar systems, so you just need the relative position of each solar system to the middle of the galaxy; and the same for each level of the above hierarchy.
Where is the “+1” to rate a post - yours is most awesome! I flagged this thread once I saw it, hoping for some “jewels”
Now about the section I quoted, for the OP, check the asset store a package called Unity Random. If after you don’t see how it relates, well then pack-up your computer and take your cat for a walk!
Regarding the “visuals” packages mentioned - DON’T DO IT! - they will completely derail you and loose you in the possibilities of creating all these cool galaxies and whatnot - I am speaking from experience here having purchased the awesome SPACE Unity package, which I DO recommend, just NOT NOW while you are in your planning stages.
I tried to do a similar approach and ended up creating a seperate program in plain C via XCode which I call Galaxy builder which does all of the heavy lifting pre-Unity. Before running the Galaxy builder, I configure the galaxy type (Elliptical or Spiral) and if Spiral, the number of arms and their characteristics. I tell it the diameter in light years and the height as well as the star system density. The program took about a month to initially develop and has been tweaked, with many, many more man-hours invested over several years now, but essentially it starts out in the center of a galaxy with a black hole and then walks out towards the galaxy edges in circular passes. It is hard to summarize the logic but the most common high level entity is a solar system (others include nebuluae, star nurseries, anomalies, black holes, etc) with 1-n stars of various types, along with 1-n planetary celestials, each with 1-n satellite celestial objects. Each celestial object has a variety of attributes/characteristics (e.g. atmosphere, lithosphere, mass, rotation). The program output is written to a series of text files which contain SQL (i used MySQL) scripts “INSERT INTO xxx” which allow me to create a database which can then be accessed by my Unity application in a variety of ways - either directly or via a web service calls. One of the other important outputs is a point file of the high level entities (e.g. solar systems). You can use a 3D point plotter program or even use Unity itself to visualize your galaxy depending on its size. In the end, even with as few as 150k high level entities (e.g. solar systems) my celestial object table can contain millions of celestial objects.
At this time, that project is on hold, but I hope that at some point maybe I will be able to revisit it again.
I want to thank you all for helping me out, I have a clearer picture. As for assets, right now I’m not interested in using them, I want to gain a much clearer picture. I plan on using primitives to represent different objects (quads for stars, spheres for planets, cubes for moons) at this stage.
I want to run by what I am currently doing, and perhaps you can see where I might be already going off in the wrong direction.
I intend on having a GameObject that is the generator of this universe. Basically all it does is run a long script, and retains all pivotal information. Now I know I need octrees to retain certain information for generating this universe as I translate through it, but so far I’m unsure how to implement it, a simplified example would be nice, but I might be asking for too much.
From reading exiguous post, I’m not sure if what you mean is that different entities are scaled according to my proximity to them? Or are they replaced with different meshes? In different zones of interest, my translation velocity is changed? I understand that different units are used in different situations, but does that mean I represent entities differently?
I will continue posting on this thread, and will gladly share all my code, as primitive as it may be, in hopes of becoming better suited on the subject and with unity.
not scaled. but when you look at the galaxy with a certain “resolution” you should only “see” things of that size. i don’t know if you want to see the galaxy from the shapceship perspective but even then you probably have some kind of starmap. the starmap should only handle star(systems) and don’t deal with planets etc and the range/unit (fe ly) of these stars is another one than those handling planets.
if you have a map of a starsystem you do not display other stars and the unit should represent the distances of planets (fe au).
when you look at the spaceship you only “see” some thousand km away so you only see the star and the closest planet/moon.
so what i mean is that you have different units for different scales as you can’t measure the distance of a planet 10k lightyears away in m or km (not even with doubles). and this is also useless as the stars should not move relative to each other as those distances are not experiences in spaceshipscale and sublighttravel but by some kind of warp/jumpdrive.
depends on how detailed you want it. if you also want to land on planet surfaces you need some kind of lod-algorithm like etherea. if you just orbit a planet you can fake it by a textured sphere. you will need to create / delete objects on a need basis so when you travel somewhere new stuff is created and old stuff deleted.
not zones but scales. so between stars you travel by jumpdrive for example. between planets you use a warpdrive (ftl). on the spaceship scale you travel sublight. your ship will always be/travel only in one scale and should use the appropriate drive for it.
i would suggest that. albeit you can warp to a star you will not travel with sublight around it. so i would utilize some kind of “navigation computer” which brings you to the entity of interest in the scale it requires. maybe have a look at eve online how it is handled. you warp between planets/moons/asteroid fields and jump through “stargates” between stars. this way you are “instantly” where you want to go. i find simulations where you manually accelerate towards a target very odd.