Hey I’m quite new to unity and have been learning for around 2 weeks, I’ve learned quite a bit and I am curious as to how I could make a terrain like this
Super-easy in Unity, at least compared to any other game engine. Here are the steps you will do:
First you need a heightmap source, and optionally a splatmap source. You can create the splatmap based on values from the heightmap, but all of that is optional and I won’t bore you here with that.
You will create a new Mesh at your procedural generation time (just new Mesh() basically).
Your code will iterate the X/Y cells in the heightmap source, asking for each height.
You will scale that appropriately in your worldspace, expanding along the X, Y and Z axes separately, and produce vertices from that. You would also supply uv coordinates to those vertices if you want texturing.
You add those vertices in and then add triangles (two for each square) to ultimately produce the mesh. You would add them to temporary arrays and only finally copy them to the Mesh itself.
Some other pointers: in normal use, a Unity3D Mesh gets put into a MeshFilter Component on a GameObject, and then a corresponding MeshRenderer to pump it out to the screen, given your choice of Material.
The heightmap source could be a function, or a grayscale PNG file heightmap you drag in, or procedurally create with a fractal plasma or any other type of effect, such as Perlin Noise.
I have not (yet) done this exact thing in my MakeGeo open source project, but I have done a lot of other geometry generation examples in there, so perhaps they would be useful to you.
As @Kurt-Dekker already explained, a terrain like the one shown in your screenshot basically only requires you to offset the height of the vertices in a plane by some value usually derived from a noise function such as Perlin Noise (often mixed with others to create more interresting terrain).
If you dont just want to generate one random square of terrain, but procedurally generate terrain while you move around the world, you will need to introduce some form of a chunking algorithm. The idea is that you can not generate an ‘infinitely’ large world in one go, so you need to break it down into chunks and only generate what you actually need / can see. You would for example determine which chunks are in some distance around the player, which of those are not yet generated, and then generate those chunks. To guarantee decent performance you will also need to introduce threading.
There are some nice tutorials on this kind of procedural terrain on youtube, like this one:
(Brackeys also made a decent one for introduction purposes, which is not nearly as in-depth as this one tho)
Be aware, however, that there is a huge difference between this kind of terrain, and voxel based terrain. While this terrain will allow you to generate ‘infinitely many’ chunks, walk over them, and even edit them to some extend, you will not be able to have caves or overhangs with this approach. If that is something you desire, you will have to look into more complex algorithms like marching cubes and 3D noise, for which it is also a lot harder to make the game run smoothly. Unless your game concept requires these kinds of terrains, i would highly recommend going with the heightmap approach.
Edit:
By the way, adding trees to this is rather easy as well. You can use a Raycast to find the surface, figure out in which direction the normal points, and then instantiate a correctly rotated tree object at that location. To make sure trees dont overlap you can use algorithms like Poisson Disc Sampling (which also works great with the chunking approach).
Adding animals will involve some form of AI, but the idea for spawning them would be similar.
Thanks for the information, but I’m just looking to create terrain from the screenshot, which is a screenshot from the first devlog of the game equilinox, however that game was made in java.