Following last week's planning, I proceeded to begin work on the terrain generation where my main goal for this week is to have a look at the generation that we were presented with at Level 5 and plan ways to improve it.
The method used to create the terrain was by creating a grid of vertices where triangles between 3 points were created, creating quads. Once the mesh of quads was complete, Perlin noise was used to determine the Y-axis. Perlin noise gives a value between 0 and 1 determined by a quad's dimensions (in this case X and Z) and multiplying that value can increase how large the Y-axis can reach. With the data for the Y-axis, I was able to change the colours dependent on the height, with the current options being
Snow
Rock (for mountain)
Grass
Water
After I added the colour choices, I decided to make the variables serializable to allow the colours to be changed within the inspector, with the intention that if the generation was used as a tool then a developer can alter the colours to allow for different planets.
I found out how Unity does seed generation while working on my collaborative project where the script on Awake will get access to the hash code of a string written and set that as the UnityEngine.Random state. If the option is chosen, then a random seed can be chosen and then set. To alter the seed generator to not be the same as the one in my other project, I have asked the generator to choose a number using my Lehmer generator, which I have altered so that there are minimum and maximum values already provided, them being 0 and 2,147,483,647 (the maximum value for 32bit integers) respectively.
Work focus
I am enjoying working on this assignment and have lots of ideas about what features I could add, but I need to keep my focus on getting the generators working before adding the smaller features, such as the change in layer colours. I will make notes as to what features I want to add but don't plan to work on them until after the key components are complete.
Comments