Lesson 83 +10 XP

Terrain System

Terrain System

Unity provides a built-in Terrain system that lets you create expansive 3D landscapes (mountains, valleys, and plains) directly inside the Editor.

Creating a Terrain

To add a terrain to your scene:

  1. Select GameObject -> 3D Object -> Terrain.
  2. This creates a large flat grid mesh and generates a Terrain Data asset in your project folder to store heightmap and styling variables.

Painting Heightmaps

Use the Terrain component's tool tab to sculpt heightmaps:

  • Raise or Lower Terrain: Click and drag with a brush to pull mountains up, or hold Shift while brushing to push valleys down.
  • Paint Holes: Hides portions of the terrain mesh, which is useful for creating caves or underground mine shafts.
  • Set Height: Flattens the terrain to a specific height level, creating flat plateaus or lakes.

Terrain Layers & Textures

To add colors and detail textures to the ground:

  1. Create a Terrain Layer asset.
  2. Assign a diffuse texture (like grass or rock) and a normal map.
  3. Add the layer to the Terrain component's Layer list.
  4. Paint textures onto the terrain using editor brushes.

Painting Trees & Detail Details

  • Trees: You can paint 3D tree prefabs onto the terrain. The engine automatically batches tree instances to keep rendering fast.
  • Detail Meshes & Grass: Use the Detail tool to paint grass billboards or small stone meshes. These sway with virtual wind configurations.

TL;DR

  • Create a Terrain via GameObject -> 3D Object -> Terrain.
  • Sculpt mountains and valleys by brushing the terrain heightmap.
  • Terrain Layers define texture overlays (grass, stone) for the landscape.
  • Paint 3D tree models and grass billboards using built-in brush tools.