Overview
Tilemaps are essential for creating 2D game backgrounds. However, manually placing tiles one by one at boundaries—grass meeting dirt, cliff corners—is extremely tedious work. Godot 4 includes the "Terrains" feature (equivalent to Autotile in Godot 3) that intelligently places appropriate tiles automatically.
This article explains how to automate tedious tile placement using Godot 4's powerful Terrains feature.
What is the Terrains Feature?
The Terrains feature lets you assign terrain information (like "this is grass" or "this is dirt") and adjacent tile patterns (Peering Bits) to each tile in your tileset. Then, when you paint in the tilemap editor, it automatically selects and places the appropriate tiles.
While similar to Godot 3's "Autotile," Godot 4's Terrains is more powerful, capable of handling complex situations where multiple terrains meet.
Three Steps to Configure Terrains
The setup may look complex, but following these steps will guide you through. Let's try with two terrain types: Grass and Dirt.
Step 1: Create a Terrain Set in TileSet Editor
- Select the
TileMapnode, click theTileSetproperty in Inspector, and open theTileSeteditor at the bottom of the screen. - In the
Terrainssection of Inspector, click "Add element" to create a newTerrain Set. - Set the
Modeof your createdTerrain Setaccording to your tileset type.Match Corners and Sides(3x3) works for most cases.
Step 2: Create Terrains
- Expand the created
Terrain Setand click "Add element" twice in theTerrainsproperty to create two Terrain slots. - Name them "Grass" and "Dirt" with distinctive
Colorvalues. Your terrain definitions are now complete.
Step 3: Set Terrain Information on Each Tile (Peering Bits)
This is the most important step.
- Select "Paint" property in the
TileSeteditor. - In the right-side Inspector, set
Properties>Terrains>Terrain Setto0(the one you just created). - Select the tile you want to configure (e.g., grass tile) from the
TileSetpanel. - Use the
Paintbrush to paint terrain information onto the selected tile. Select "Grass" (0) in theTerrainproperty and paint which parts of the tile are grass.

Correctly setting the Peering Bits (the center 3x3 grid) is crucial. These define the rule "when should this tile be displayed based on surrounding tiles?"
- Center square: This tile's own terrain (e.g., Grass)
- Surrounding 8 squares: Adjacent tiles' terrains (e.g., Dirt, or empty space)
For example, for the top-right corner of a grass area, you'd set center, left, bottom-left, and bottom as "Grass," with the rest as "Dirt" or "empty." Apply this configuration to all boundary tile patterns (16-tile or 47-tile sets, etc.).
Painting with the Terrain Brush
Once configuration is complete, return to the TileMap editor and select the Terrains tab. You should see your configured terrains (Grass and Dirt) in the palette.
Simply select the terrain you want to paint and drag across the canvas. Godot automatically places appropriate boundary tiles following the Peering Bits rules. Level creation becomes intuitive—a far cry from manually selecting tiles one by one.
Summary
Setting up the Terrains feature takes some initial effort. However, once configured, your level design efficiency improves dramatically. The benefits are immeasurable, especially when creating large maps or frequently revising designs.
Start by trying the Terrains feature with just two simple terrain types and experience its convenience firsthand.