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.

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.

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.

What you’re exactly looking for is here, the tutorial series Unity itself offers for procedural cave generation.