Road Creation
Build spline-based roads that conform to terrain surfaces.
Introduction
Roads connect your game world. This guide covers creating spline-based roads that follow terrain contours, with proper texturing and intersection handling.
Guide 3 of 25
Screenshot
Step-by-Step Guide
Create a road spline
Add a Spline object. Click on the terrain to add control points — the road follows the spline path.
Conform to terrain
Enable Snap to Terrain so the road follows ground elevation. Set an offset (0.1m) to prevent Z-fighting.
Set road width
Configure width: 8m for highways, 4m for country roads, 2m for paths.
Apply road material
Assign a road texture. Use tiling along the spline length for consistent markings.
Add road markings
Create a second material lane for center lines. Use alpha blending for painted lines.
Handle intersections
Create flat intersection meshes at crossings. Blend materials at edges for smooth transitions.
FluxScript Example
Here is a complete FluxScript implementation for this guide:
on start {
points = [vec3(0,0,0), vec3(20,0,10), vec3(40,0,15), vec3(60,0,30), vec3(80,0,50)]
road = world.createSpline(points)
road.setWidth(6)
road.setTerrainSnap(true)
road.setTerrainOffset(0.1)
road.setMaterial("asphalt")
road.setTiling(1, 10)
markings = road.addOverlay("center_line")
markings.setMaterial("road_markings")
markings.setWidth(0.3)
markings.setDash(3, 5)
road.setLOD([{ distance: 50, segments: 32 }, { distance: 150, segments: 8 }])
road.rebuild()
}Node Graph Example
Prefer visual programming? Here is the equivalent Node Graph:
[On Start] --> [Define: 5 waypoints]
--> [Create Spline] --> [Set Width: 6m, Snap: true]
--> [Set Material: asphalt, Tiling: (1,10)]
--> [Add Overlay: center_line, dashed]
--> [Set LOD: 2 levels] --> [Rebuild]Optimization Tips
Keep your implementation fast and efficient with these optimization tips:
- Use LOD for road segments. Distant sections can use fewer spline subdivisions without visible quality loss.
- Keep road splines simple — fewer control points means smoother curves and faster generation.
- Snap roads to terrain with a small offset (0.05-0.1m) to prevent Z-fighting.
- Pool road segment meshes if generating dynamically to avoid GC spikes.
Common Mistakes
Roads floating above terrain
Enable terrain snapping and set a small offset. Rebuild roads if terrain changes.
Textures stretching at curves
Use distance-based UV mapping instead of parameter-based for consistent texture density.
