How Can I make 3D Roads?

So the title kind of explains it, I need to make 3D roads similar to Unturned’s road system
how do I accomplish this?

I should probably note that it will need to go across the terrain too, so it has to be able to manipulate itself to the terrain and look natural, I have a 3D model for the road but I just need to be able to place it via nodes and the need to connect to each other.

Also sorry for asking a lot of questions lately, I don’t know if that bothers some people or not but I just recently found out that I was supposed to leave my questions in “Default” and they get answered now so I can finally get some assistance on all of the problems I’ve been having, most have been resolved thanks to you guys!

What you want to do isn’t trivial but it looks like that road system you linked creates a procedural mesh by connecting quads between given waypoints. If that’s what you’re after then you’ll need to start by creating a single quad procedurally and then expanding by increasing the number of vertices for each road section. Here’s the bare-bones of how to create a grid of quads procedurally:

``````public void CreateMesh(int size)
{
List<Vector3> verts = new List<Vector3>(); // Index used in tri list
List<int> tris = new List<int>(); // Every 3 ints represents a triangle
List<Vector2> uvs = new List<Vector2>(); // Vertex in 0-1 UV space
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
uvs.Add(new Vector2((float)i / size, (float)j / size));
if (i == 0 || j == 0) continue; // First bottom and left skipped
tris.Add(size * i + j); //Top right
tris.Add(size * i + (j - 1)); //Bottom right
tris.Add(size * (i - 1) + (j - 1)); //Bottom left - First triangle
tris.Add(size * (i - 1) + (j - 1)); //Bottom left
tris.Add(size * (i - 1) + j); //Top left
tris.Add(size * i + j); //Top right - Second triangle
}
}
Mesh mesh = new Mesh();
mesh.vertices = verts.ToArray();
mesh.uv = uvs.ToArray();
mesh.triangles = tris.ToArray();
mesh.RecalculateNormals();

GameObject grid = new GameObject("Grid");