Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Godot Tilemap?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-godot-tilemap)
---
name: godot-tilemap
description: >-
Godot tile levels: TileMapLayer and TileSet atlases, terrains and autotiling, physics and
navigation layers, levels built from data.
---
# godot-tilemap — tiles, terrains and levels as data
Each layer is a `TileMapLayer` node sharing one `TileSet`; a level from data is a loop of
`set_cell()` calls. The tiles carry the collision, one-way flags and navigation, so a level
never draws them separately.
## Load what the situation needs
| The situation | Read |
|---|---|
| A project on the old `TileMap` node; code that indexes layers by number | `reference/tileset.md` → "TileMap is the old node" |
| A tile sheet arrives from the art pipeline and needs a `TileSet` | `scripts/tileset_from_sheet.py`, then `reference/tileset.md` → "Building a TileSet" |
| Solid, one-way, walkable tiles; custom data such as "surface" or "hazard" | `reference/tileset.md` → "What a tile carries" |
| Edges and corners that should pick themselves (autotiling) | `reference/terrains.md` |
| A level from text rows, JSON or a Tiled map | `resources/level_from_data.gd`, then `reference/levels-from-data.md` |
| "Which tile did the courier land on?"; a moving layer | `reference/tileset.md` → "The layer node at run time" |
| A body falls through tiles placed this frame; no path across fresh tiles | `reference/levels-from-data.md` → "After the cells are set" |
| The courier walks behind a chimney; layers draw in the wrong order | `godot-2d-rendering` → `reference/draw-order.md` |
| Light and shadow from tiles | `godot-2d-rendering` |
| Collision layers and masks, tunnelling, a ray that misses | `godot-physics` |
| The courier's motor on the tiles; one-way drop-through | `godot-2d-controller` |
| Drawing the tile art itself | `codex-visual` (game-assets) |
| Pixel-art import settings for the sheet | `godot-2d-sprites` |
## TileMap and TileMapLayer
The class reference's own description of `TileMapLayer` says `TileMap` is deprecated and that
several `TileMapLayer` nodes replace one `TileMap`. New levels use `TileMapLayer`, one node per
layer, siblings sharing one `TileSet`. Moving an old level is mechanical: drop the layer index
from every call and hold a node reference instead (the table in `reference/tileset.md`).
## A TileSet from a sheet
`scripts/tileset_from_sheet.py` writes the `.tres` text Godot's `ResourceSaver` writes for the
same TileSet, from the sheet's size alone: one atlas source over the grid, physics layer 0 with a
full-tile square on the solid tiles (one-way on the one-way ones), navigation layer 0 on the
walkable tiles, and any 4x4 block as a match-sides terrain.
```bash
python3 scripts/tileset_from_sheet.py art/rooftop_tiles.png --tile 16 --margin 1 --separation 1 \
--texture-path res://art/rooftop_tiles.png --out art/rooftop_tiles.tres \
--solid-block 0,0,4,4 --one-way 4,0 --walkable 5,0 --walkable 5,1 --terrain-sides 0,0=Roof
python3 scripts/tileset_from_sheet.py sheet.png --tile 16 --solid-all \
--texture-path res://art/sheet.png --out art/sheet_tiles.tres
python3 scripts/tileset_from_sheet.py --selftest
```
Cells are atlas `X,Y`, column and row from the top left; `--solid`, `--one-way` and `--walkable`
repeat, `--solid-block X,Y,W,H` marks a rectangle, `--solid-all` and `--walkable-all` mark every
tile, `--tile-height` makes tiles non-square. Exit 0 written, 1 a usage error or refused input (no
tile fits, a cell outside the grid, a terrain block past the edge), 3 the sheet is not a readable
PNG or the output cannot be written. Import the sheet before the `.tres` loads.
The same TileSet can be built at run time: `resources/level_from_data.gd` → `atlas_tileset()`
and `add_side_terrain()`. The selftest builds it both ways and compares every tile.
## Levels from data
`resources/level_from_data.gd` (static functions; `preload()` it, no `class_name`):
| Function | Does |
|---|---|
| `atlas_tileset(texture, tile_size, solid, one_way, walkable, margins, separation)` | a `TileSet` with atlas source 0, physics layer 0, navigation layer 0 |
| `add_side_terrain(tile_set, block, name)` | a 4x4 block becomes a match-sides terrain; returns its set |
| `fill_rows(layer, rows, legend, origin)` | one character per cell; terrain cells painted together afterwards |
| `fill_json(layer, text, tiled_layer)` | `{"legend", "rows"}` or a Tiled map; -1 for anything else |
| `tiled_layer_names(data)`, `fill_tiled(layer, data, layer_name, sources)` | Tiled tile layers in drawing order; CSV data, flip bits to transform flags |
## What the selftest proves
`--selftest` writes a sheet, checks the command line's exits, then imports a throwaway project
outside the repository and runs it headless: the written TileSet loads with the right grid,
margins and terrain; 24 of 24 tiles match the run-time build; a text level sets the expected cells
and the terrain picks the expected edge tiles; the JSON level matches it; a Tiled map gives the
expected atlas coords and flip flags, through `fill_json()` too, while base64 data, an unknown
layer and an external tileset set nothing; a body stands on a solid tile and another on a one-way
tile; the collision names the layer and the cell under the contact point; a path goes round a
wall of non-walkable tiles. Any engine or script error in the import or the run fails it. It
needs Godot (`--godot PATH` or `GODOT_BIN`) and exits 3 without one.
## Discipline
- **One `TileSet`, many layers.** Ground, trim, one-way ledges and decoration are sibling
`TileMapLayer` nodes on the same `TileSet`; a second `TileSet` per layer splits the physics
and terrain setup in two.
- **The tile decides, not the level.** Collision, one-way, navigation and custom data live on
the tile; a level file names tiles and nothing else.
- **Paint terrains per terrain.** Gather the cells, then one `set_cells_terrain_connect()` call
per terrain.
- **Wait for the cells.** Changes apply at the end of the frame and paths from the navigation
map's second iteration: wait a frame before physics, poll for paths.
- **Generated is checked in.** A `.tres` written by the script goes into version control with
the command that wrote it, so the next sheet is one command.