Up to date

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

Using TileSets

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 let you draw a layout by "painting" tiles onto a grid, which is much faster than placing individual Sprite2D nodes one by one. Second, they allow for larger levels because they are optimized for drawing large numbers of tiles. Finally, they allow you to add greater functionality to your tiles with collision, occlusion, and navigation shapes.

To use tilemaps, you will need to create a TileSet first. A TileSet is a collection of tiles that can be placed in a TileMap node. After creating a TileSet, you will be able to place them using the TileMap editor.

To follow this guide, you will need an image containing your tiles where every tile has the same size (large objects can be split into several tiles). This image is called a tilesheet. Tiles do not have to be square: they can be rectangular, hexagonal, or isometric (pseudo-3D perspective).

Creating a new TileSet

Using a tilesheet

This demonstration will use the following tiles taken from Kenney's "Abstract Platformer" pack. We'll use this particular tilesheet from the set:

Tilesheet example with 64×64 tiles

Tilesheet with 64×64 tiles. Credit: Kenney

Create a new TileMap node, then select it and create a new TileSet resource in the inspector:

Creating a new TileSet resource within the TileMap node

Creating a new TileSet resource within the TileMap node

After creating the TileSet resource, click the value to unfold it in the inspector. The default tile shape is Square, but you can also choose Isometric, Half-Offset Square or Hexagon (depending on the shape of your tile images). If using a tile shape other than Square, you may also need to adjust the Tile Layout and Tile Offset Axis properties. Lastly, enabling the Rendering > UV Clipping property may be useful if you wish tiles to be clipped by their tile coordinates. This ensures tiles cannot draw outside their allocated area on the tilesheet.

Set the tile size to 64×64 in the inspector to match the example tilesheet:

Setting the tile size to 64×64 to match the example tilesheet

Setting the tile size to 64×64 to match the example tilesheet

If relying on automatic tiles creation (like we're about to do here), you must set the tile size before creating the atlas. The atlas will determine which tiles from the tilesheet can be added to a TileMap node (as not every part of the image may be a valid tile).

Open the TileSet panel at the bottom of the editor, then click the "+" icon in the bottom-left corner to add a new atlas:

Creating a new atlas in a TileSet resource using the bottom panel

Creating a new atlas in a TileSet resource using the bottom panel

After creating an atlas, you must assign a tilesheet texture to it. This can be done by choosing it on the left column of the bottom panel, then clicking the value of the Texture property and choosing Quick Load (or Load). Specify the path to the image file using the file dialog that appears.

Loading a tilesheet image in the newly created TileSet atlas

Loading a tilesheet image in the newly created TileSet atlas

After specifying a valid