Skip to content

User guide: Custom road meshes

Patrick W. Crawford edited this page Apr 28, 2024 · 1 revision

This page provides an overview of how to hand model custom road pieces to use in Godot.

Context

While the easiest way to create roads is by using the procedurally generated segments this addon provides, sometimes you need to have more custom meshes or need more control.

However, it is still nice to get all the other benefits the Road Generator provides, namely AI path following lanes and connection/snapping tools. This tutorial shows a way to get the best of both, and how to start with the procedurally generated geometry in order to save a little time.

For the purpose of this tutorial, we are assuming you have a section of road in your game you want to convert into a custom section. If you instead wanted to start with a pre-made custom step, you can skip to a further along step. In this case, let's use the case example of adding a bridge piece to your game.

Tutorial steps

  1. Create your road network, with these best practices in mind:
    • Use a RoadManager root node, which contains children
    • Use RoadContainers to group logical sections together, typically one container = 1 stretch of road between two intersections.
    • When using containers, though it doesn't impact performance, it's worth trying to make the original of the RoadContainer be near the actual RoadPoints it contains (it's more annoying to move this later).
    • Once https://github.com/TheDuckCow/godot-road-generator/issues/147 is done, you can also nest multiple containers together to give more hierarchy and structure.
    • Use the connection tool (+ mode) to bridge the gap between two RoadContainers to ensure the entire network gets closed up.
  2. Identify one RoadContainer to convert into hand-modeled
  3. Right click that container, and save to a scene.
    • Notice how the RoadPoints of this RoadContainer are now more grayed out and cannot be directly selected.
    • For all intents and purposes, the macro road manager now treats your saved subscene as a static block, like a puzzle piece.
  4. Open the new scene and save it out to GLTF. In godot 3.5, this is: Project > Tools > Export GLTF
    • Godot automatically will re-import this model after you export this, trying to treat it as a part of your project files. We suggest you export it into a new temp folder within your project, then manually move it outside your godot project after.
  5. Now open this GLTF file in any 3D modeler, and edit away!
    • For the purpose of this tutorial, we'll showcase using Blender
    • Even if you completely throw away the original geometry provided by the Road Generator, you still can use it as a reference for the positions of the RoadPoints which are exported as empties.
  6. Once ready, export the minimal part of your new mesh out to a new GLTF (suggested), this time into the godot project structure in a final persistent location.
  7. Back in Godot, load up your saved RoadContainer scene. Select that root container node, and uncheck the box for "Create geo"
    • This is how we'll tell the addon to skip the mesh creation stage, while keeping all the other connection-related tooling.
  8. Drag in your new gltf export, making sure the transforms are cleared out.
  9. Return to your source full scene, and you should find your custom model in place ready to go.

Going further

This above example worths the same for any RoadContainer, including those that have more than just two edge RoadPoints. That means this is a great way to create custom geometry for your intersections, something the plugin is not highly capable of doing just yet.

Current support: Godot 3.5+ Godot 4 planned for v1.0 of this addon (details)

Wiki pages

Clone this wiki locally