Up to date

This page is up to date for Godot 4.0. If you still find outdated information, please open an issue.

Using TileMaps

See also

This page assumes you have created or downloaded a TileSet already. If not, please read Using TileSets first as you will need a TileSet to create a TileMap.

Introduction

A tilemap is a grid of tiles used to create a game's layout. There are several benefits to using TileMap nodes to design your levels. First, they make it possible to draw the layout by "painting" the tiles onto a grid, which is much faster than placing individual Sprite2D nodes one by one. Second, they allow for much larger levels because they are optimized for drawing large numbers of tiles. Finally, you can add collision, occlusion, and navigation shapes to tiles, adding greater functionality to the TileMap.

Note

Godot 4.0 has moved several per-tile properties, such as tile rotation, from TileMap to TileSet. Individual tiles can no longer be rotated while in the TileMap editor. Instead, the TileSet editor must be used to create alternative rotated tiles.

This change allows for greater design consistency, as not every tile needs to be rotated or flipped within a TileSet.

Specifying the TileSet in the TileMap

If you've followed the previous page on Using TileSets, you should have a TileSet resource that is built-in to the TileMap node. This is good for prototyping, but in a real world project, you will generally have multiple levels reusing the same tileset.

The recommended way to reuse the same TileSet in several TileMap nodes is to save the TileSet to an external resource. To do so, click the dropdown next to the TileSet resource and choose Save:

Saving the built-in TileSet resource to an external resource file

Saving the built-in TileSet resource to an external resource file

Creating TileMap layers

As of Godot 4.0, you can place several layers in a single TileMap node. For example, this allows you to distinguish foreground tiles from background tiles for better organization. You can place one tile per layer at a given location, which allows you to overlap several tiles together if you have more than one layer.

By default, a TileMap node automatically has one premade layer. You do not have to create additional layers if you only need a single layer, but if you wish to do so now, select the TileMap node and unfold the Layers section in the inspector:

Creating layers in a TileMap node (example with "background" and "foreground")

Creating layers in a TileMap node (example with "background" and "foreground")

Each layer has several properties you can adjust:

  • Name: A human-readable name to display in the TileMap editor. This can be something like "background", "buildings", "vegetation", etc.

  • Enabled: If true, the layer is visible in the editor and when running the project.

  • Modulate: The color to use as a multiplier for all tiles on the layer. This is also multiplied with the per-tile Modulate property and the TileMap node's Modulate property. For example, you can use this to darken background tiles to make foreground tiles stand out more.

  • Y Sort Enabled: If true, sorts tiles based on their Y position on the TileMap. This can be used to prevent sorting issues with certain tile setups, especially with isometric tiles.

  • Y Sort Origin: The vertical offset to use for Y-sorting on each tile (in pixels). Only effective if Y Sort Enabled is true.

  • Z Index: Controls whether this layer is drawn in front of or behind other TileMap layers. This value can be positive or negative; the layer with the highest Z Index is drawn on top of other layers. If several layers have an equal Z Index property, the layer that is last in the list of layers (the one which appears at the bottom i