On-a-sphere
The main playing surface of Onasphere is the sphere. It originally started as a simple Unity primitive, it then turned into a Maya model, and finally settled on a procedurally generated icosphere. This allowed me to generate an infinite number of new playing surfaces which I hope keeps the game more interesting.
Starting with nothing
Google is your friend. I feel that the best way to tackle a new problem is to first see if anyone else has already solved it. I started with a great post from Andreas Kahler that describes how to generate an Icosphere at runtime. The comments helped with some Unity/C# code and that was enough to get things started. I found some good Simplex Noise reference at Cabbynode Games and after evaluating a few other noise functions I found that it worked the best.
I added some sliders for subdivision level and noise scale, frequency, and cutoff. This gave me a good set of basic tools for experimentation. Once I had gotten started I stumbled upon the game Caeludum by Tyler Hiemke who was doing some very similar things (although very different gameplay). He gave me some tips on vertex colouring for low poly which helped the overall quality.
Adding the ability to do non-linear scaling allowed me to make things like asteroids.
Colliding
The collisions can either be simple spheres or a collision mesh. The collision mesh is generated using the same parameters of the sphere but with a bit of smoothing applied so that the resulting mesh isn't as jagged. Jaggies make for some nasty collisions!
Adding life
Now that I had a basic procedurally generated sphere I needed to add some life. This came in the form of colour, props, and atmospherics.I initially used vertex colouring for the triangles but, after hitting the 65k vertex limit in Unity, I decided to break up my mesh based on colour. For each of my planets I have a custom colour palette consisting of colours, materials, textures, and a cutoff threshold which can be swapped at runtime. I have recently added random colour generation based on colour theory.
The next thing I added was layer based props which would be randomly placed depending on the previous colour layer. This is currently disabled but will eventually support buildings, trees, rocks, or whatever else makes sense.The last thing I added was water and atmosphere. They are both separate spheres with noise functions applied. The water has noise applied to the position of the vertices while the atmosphere has noise applied to the colour of the vertices to simulate clouds. The atmosphere isn't quite right yet so it's been disabled.
Putting a hex on it
Hexes are all the rage these days and I think they're pretty cool too. I was originally colouring things based on triangle but it resulted in some pretty odd looking configurations. When I was looking at Caeludum I noticed that it mainly used hexes for colour. Once I realized this it made total sense and I knew I had to add something similar. I scratched away in my notebook for a few hours and came up with a way to procedurally generate hex assignments for my spheres.
What's next?
I'm having a really hard time focusing on the gameplay because it's so much fun tweaking the planet. I think I could spend all my time making a random planet generator but that's not really the point of the game. A few things I would like to add in the future include: suns, gas giants, and crystalline planets.
Great read! Love these kind of articles. Keep them coming. :-)