- Home /
Random 2D Terrain Generating
Hi. I am fairly new to unity and I have only created about 2 games. I would want my next project to be a game where you "Mine" the ground and there are randomly generated dirt stone and for example iron being generated as you "Mine" down lower. I am sure I am able to get the mining bit by myself. The only thing I need help with is making the terrain generate randomly as the player "Mines" deeper and the camera to follow the player. If I posted this in the wrong place sorry. Any help is appreciated.
Answer by jdean300 · Jun 26, 2016 at 06:21 AM
Might be able to look into perlin/simplex noise generation. 2D Perlin/simplex noise generates a 2d grid of values, usually between -1 and 1, that rise and fall smoothly. Here is an example of it's output:
You could then use that and the vertical depth to assign different ore types to the terrain. For example, the blue in the picture represents values close to -1 - you could say any point in the game world with a depth greater than 40, with a noise value from -1 to -.8 is iron.
I haven't tried using perlin/simplex noise generation like this before, but it seems like it may work.
https://github.com/deanljohnson/EnviroGen This is a link to a generator I created to give me that image. It's far from finished and is a big project, but all the code is there. Note this is not done in Unity, but the code to actually generate the noise values is not specific to anything.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
SetAlphaMaps Opacity Gradient 0 Answers
Procedural 2D Tilemap Terrain - Mesh or Unity Tilemaps? 0 Answers
Multiple Cars not working 1 Answer
[C#] Wondering what is amiss with my 1D Perlin Noise Terrain Generator? 2 Answers