AppleyAppley Docs
Docs/Terrain

Road Creation

Build spline-based roads that conform to terrain surfaces.

14 min read Intermediate Updated 2026-07-01 v2.0 ~43 min to complete

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

This is part of the Intermediate Guides collection. Category: Terrain. Estimated completion: 43 minutes. Difficulty: Intermediate.

Screenshot

Road Creation
Road Creation

Step-by-Step Guide

1

Create a road spline

Add a Spline object. Click on the terrain to add control points — the road follows the spline path.

2

Conform to terrain

Enable Snap to Terrain so the road follows ground elevation. Set an offset (0.1m) to prevent Z-fighting.

3

Set road width

Configure width: 8m for highways, 4m for country roads, 2m for paths.

4

Apply road material

Assign a road texture. Use tiling along the spline length for consistent markings.

5

Add road markings

Create a second material lane for center lines. Use alpha blending for painted lines.

6

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:

Road Creation — FluxScript
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:

Road Creation — 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.