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.
Thanks in advance!
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++)
{
verts.Add(new Vector3(i, 0, 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");
grid.AddComponent<MeshFilter>();
grid.AddComponent<MeshRenderer>();
grid.GetComponent<MeshFilter>().mesh = mesh;
// Load a material named "GridMat" from a folder named "Resources"
MaterialgridMat = Resources.Load<Material>("GridMat");
grid.GetComponent<Renderer>().material = gridMat;
}
That should be enough to get you started, but you’ll have to adjust it to be a “grid” with one base square and x waypoints for height along with the custom positions from the waypoints. As for connecting the roads… that’s a whole other beast entirely and one you might want to focus on once you have roads in place.