Random road generator algorithm

Hello. I need to make a randomly generated road system for a project that I’m working on. The thing that I primarily need help with is how to make the road work with roblox terrain. I already know how to do all of the trigonometry and math needed to fit the triangles / road peices together perfectly, and then append road peices to the end of a road, and then turn them by a certain angle. But what I primarily need help with is making it so the road fits on the roblox terrain. I could just set the height of the road to one set value, but it will look unnatural, and there will be places where the road goes / floats above, or under / through the terrain. I’m confident that I could come up with an algorithm for this on my own, but I thought it would be a bit helpful to ask this question on the devforum first.

Pictures

Here is a 2D diagram that I drew of this problem, note that this is supposed to be in 3D, and the diagram is just a side view of a road.


The road in that picture is the black dashed line.

One thing that I thought about doing was using interpolation to match the terrain height to the height of the road in the places where there are roads, but I’m wondering if there is a better way of doing this.

1 Like