Curved roads

Hello,
I believe that this is in the correct section. If not, please forgive me. Its a problem I have that could arguably be in either the modeling section, or the scripting section.

Ok, so I would like to make a game where you glide down a mountain road on a long-board avoiding cars. I believe this will probably be a summer-long project, so I am taking the time to go slow and do everything right. The first thing I want to play around with is map generation.
The way I am contemplating is this: have a few different road sections modeled in blender.

  • straight road
  • slightly bent to the right
  • medium bent to the right
  • large bent to the right
  • slightly bent to the left
  • medium bent to the left
  • large bent to the left

Here is an example road I made very quickly in blender:


I am wondering how I can connect many of these roads together so that they form a smooth line?
What I mean, is I want the end of one to connect to the end of the next one. Is it possible to set “pins” of some sort on the end corners of the road section, and then somehow get the “pins” on the new road section to line up? This is difficult for me because I need to know both the position AND the rotation of the prefab road piece I instantiate.

make them all a uniform size so they all snap together, like a slot car set.

One method is (with the segments as prefabs) include a pair of anchor objects (just empty GameObjects, findable by reference or tag) aligned to the start and end of the track section. When adding a new segment, you position and align it such that the end-anchor of the last existing segments lines up with the start-anchor of the new one.

With multiple end-anchors, you can use this for branching roads as well.

2 Likes

Thanks! This was helpful. I was thinking something like this could work, but having you spell it out helped me realize where I could go with this idea. My main issue however is rotation. For example, if the road sections were straight then this would be easy to implement. but sense they are curved it become more difficult. For example the first section is easy, I just place the prefab anywhere. But the second one is more difficult. For example, if I place the road section at the end, without thinking of rotation, I will get something like this:
2610735--183037--road_2.PNG
What I want though is this:
2610735--183038--road_3.PNG

This method may help : Bake Your Own 3D Dungeons With Procedural Recipes | Envato Tuts+

Have you thought about maybe using splines and lofting a road along that?