Tiles (TileMapLayer / TileSet)
tilesBuild 2D tile maps in Godot: create TileSets from atlas images, add TileMapLayer nodes, and paint cells, terrain, or whole levels from ASCII art. Every edit is undoable.
Instructions
2D tile maps with TileMapLayer nodes (the deprecated TileMap node is never used). Build a TileSet from an atlas image in one call (tiles auto-detected from non-transparent cells, collision, terrains for autotiling, custom data), add layers, then paint: cells/rects/lines, terrain autotiling, or whole levels from ASCII art. All painting is undoable. Coordinates are map cells, tiles are atlas coords [x, y].
Actions:
create_tileset: {path: res://tiles/world.tres, texture: res://art/tiles.png, tile_size=[16,16], separation?=0|[x,y], margin?=0|[x,y], all_tiles?=false (else only non-transparent cells get tiles), overwrite? (layers of open scenes using the old TileSet are relinked), tile_shape?, physics_layers?: [{collision_layer: [1|'world'], collision_mask: [...]}], full_collision?: bool (full-square polygon on every tile) | collision_tiles?: [[x,y] | {tile:[x,y], points?:[[x,y]...] (tile-centered), one_way?}], terrains?: [{name, color?, mode?: match_corners_and_sides|match_sides|match_corners, block?: [x,y] (origin of a 3x3 autotile block: corners/edges/center; or {origin, size}), tiles?: [[x,y]...] (fully this terrain) | {"x,y": 'all' | ['top','right','bottom_right',...] | '010/111/010' 3x3 mask | {center:'grass', top:'dirt', ...}}}], custom_data?: [{name, type: int|float|bool|string|vector2|color..., values?: {"x,y": value}}]} create a TileSet from an atlas image. No art yet? assets.placeholder {kind: 'tileset'} makes one.
info: {path: res://x.tres | TileMapLayer node, tiles?=true} sources, atlas grid, tile coords (with collision/terrain/custom data per tile), physics layers, terrain sets, custom data; for a layer also used cells/rect.
create_layer: {tileset: res://x.tres, name?='TileMapLayer', parent?='.', position?, index?, props?: {z_index, y_sort_enabled, collision_enabled, ...}} add a TileMapLayer node. Use several layers for background/ground/decoration.
paint: {path: layer, cells: [[x,y],...] | rect: [x,y,w,h] | line: [[x1,y1],[x2,y2],...], tile: [ax,ay] (or [[ax,ay],[bx,by]] to pick randomly for variety), source?=first, alternative?=0} set cells to a tile.
fill_rect: {path, rect: [x,y,w,h], tile: [ax,ay], border?: [ax,ay] (different tile on the edge), hollow?: bool (only the edge; interior erased)} fill a rectangle, e.g. rooms with walls.
erase: {path, cells | rect | line} remove tiles.
terrain: {path, cells | rect | line, terrain: name|index, terrain_set?=0, mode?: connect|path, ignore_empty_terrains?=true} paint with terrain autotiling (the TileSet needs terrains, see create_tileset). Use -1 as terrain to erase terrain-aware.
from_ascii: {path, rows: ['##########', '#........#', '#..gggg..#', '##########'], legend: {'#': [3,0], '.': null (erase), 'g': {terrain: 'grass'} | 'grass', 'w': {tile: [1,0], source?, alternative?}}, origin?=[0,0], clear?=false} paint a whole level from ASCII art; spaces leave cells untouched. Best way to lay out levels.
read: {path, rect?: [x,y,w,h] (default: used rect), legend?: same legend as from_ascii ({char: [ax,ay] | null (empty char) | 'grass' | {terrain: 'grass'}}), cells?: bool} used cells plus an ASCII picture (terrain cells map to their terrain's char; other unknown tiles get auto characters, returned in auto_legend). Use it to check what's painted.
clear: {path} erase every cell of the layer (undoable).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cell | No | [x, y] single cell. | |
| line | No | [[x1, y1], [x2, y2], ...] polyline of cells. | |
| mode | No | terrain: connect (areas) or path (roads/rivers). | |
| name | No | Node name. | |
| path | No | TileMapLayer node path (scene-relative), or res:// TileSet path for create_tileset/info. | |
| rect | No | [x, y, width, height] in cells. | |
| rows | No | ASCII rows: list of strings (one per map row) or one string with line breaks. | |
| tile | No | ||
| cells | No | [[x, y], ...] map cells. | |
| clear | No | from_ascii: clear the layer first. | |
| index | No | Child index. | |
| props | No | Property map. Values are coerced to the property type: numbers, [x,y], 'Vector2(1,2)', '#ff8800', 'res://file', {"type":"RectangleShape2D","size":[32,32]} for new resources, enum names as strings. | |
| scene | No | res:// scene to operate on; opened in the editor if needed. Defaults to the currently edited scene. | |
| tiles | No | info: include per-tile listing (default true). | |
| action | Yes | What to do. See the tool description for each action's parameters. | |
| border | No | [ax, ay] border tile for fill_rect. | |
| hollow | No | fill_rect: only the outline. | |
| legend | No | {char: [ax, ay] | null | {tile, source?, alternative?} | {terrain}}. | |
| margin | No | ||
| origin | No | [x, y] map cell of the first ASCII character. | |
| parent | No | Parent node path (default '.'). | |
| source | No | TileSet source id (default: first source). | |
| terrain | No | ||
| texture | No | res:// atlas image for create_tileset. | |
| tileset | No | res:// TileSet for create_layer. | |
| position | No | [x, y] layer position. | |
| terrains | No | Terrain definitions (see create_tileset). | |
| all_tiles | No | create_tileset: create tiles for every cell, even fully transparent ones. | |
| overwrite | No | Replace an existing TileSet file. | |
| tile_size | No | [w, h] tile size in pixels (default [16, 16]). | |
| separation | No | ||
| tile_shape | No | square | isometric | half_offset_square | hexagon. | |
| alternative | No | Alternative tile id (default 0). | |
| custom_data | No | Custom data layers [{name, type, values?}]. | |
| terrain_set | No | Terrain set index (default 0). | |
| full_collision | No | Full-square collision on every tile. | |
| physics_layers | No | [{collision_layer, collision_mask}] layer numbers or names. | |
| collision_tiles | No | Tiles that get collision: [[x,y]] or {tile, points?, one_way?}. | |
| ignore_empty_terrains | No | terrain: ignore empty terrain bits when matching. |