A Godot tile map is a way to take a sprite sheet containing small images such as grass, roads, walls, and water, split it into regular grid cells, and then paint a level with those tiles.
In Godot 4.x, especially for new projects after 4.3, use TileMapLayer. The old TileMap node is deprecated. The current recommendation is to use one TileMapLayer for each map layer. This makes the node tree clearer and fits Godot’s node-based workflow better.
The official documentation also states that TileMapLayer is a node for 2D tile-based maps, and that it uses a TileSet to create grid maps. If you need multiple layers, use multiple TileMapLayer nodes.
Official docs:
https://docs.godotengine.org/en/stable/classes/class_tilemaplayer.html
https://docs.godotengine.org/en/latest/tutorials/2d/using_tilemaps.html
Two Core Concepts
Tile maps revolve around two things:
TileSet
TileMapLayer
TileSet is the tile library. It stores:
- Grass, dirt, walls, water, roads, and other tiles.
- Collision shapes for individual tiles.
- Terrain auto-connection rules.
- Navigation, occlusion, and custom data.
TileMapLayer is the canvas. It uses tiles from the TileSet to draw the map.
Start with a structure like this:
1
2
3
4
5
6
|
World (Node2D)
├─ Ground (TileMapLayer) # Grass, roads, floors
├─ Decoration (TileMapLayer) # Flowers, cracks, shadows
├─ Walls (TileMapLayer) # Walls and obstacles
├─ Objects (Node2D) # Chests, doors, NPCs, coins
└─ Player (CharacterBody2D)
|
Layering has several advantages:
- Ground and walls do not get mixed together.
- Display order is easier to control.
- You can hide a single layer.
- Only the wall layer needs collision; the ground layer can stay simple.
- Codex gets a clearer node structure when writing scripts later.
Create Your First Tile Map
Prepare a tile image first, for example:
Every cell inside the image should use the same size. Common sizes are:
1
2
3
|
16 × 16
32 × 32
64 × 64
|
If each tile in the source art is 32 × 32, the Tile Size in your TileSet should also be 32 × 32.
Add a TileMapLayer
Add this to the scene:
1
2
|
Node2D
└─ TileMapLayer
|
Rename the TileMapLayer to:
Select Ground, then find this in the Inspector:
Click:
1
2
|
<empty>
→ New TileSet
|
Then open the new TileSet resource and set Tile Size to the source tile size, for example:
Add the Tile Image
After selecting Ground, the TileMap / TileSet editor panel appears at the bottom.
Drag tileset.png into the TileSet panel and choose automatic tile creation. Godot will split the image into tiles according to Tile Size.
After this step, the TileSet contains drawable tiles, and the Ground TileMapLayer can use them to paint the map.
Paint the Map
Switch to the TileMap panel at the bottom:
- Pick a grass tile.
- Paint with the pencil tool.
- Delete with the eraser.
- Use the rectangle tool to fill a region quickly.
- Use the fill tool to fill a connected area.
Do not start with a huge map. Draw a small 20 × 15 map first, with only grass, walls, and a player spawn point.
Add Collision to Walls
Do not add collision to every ground tile. Usually only non-walkable tiles need collision:
- Walls.
- Rocks.
- Fences.
- Water boundaries.
- Cliffs.
Select the TileSet resource and find:
Click:
A common setup is:
1
2
|
Collision Layer: 1
Collision Mask: 1
|
Then in the bottom TileSet panel:
- Switch to the collision or physics painting tools.
- Select a wall tile.
- Draw a rectangular or polygon collision shape over the wall area.
This lets different tiles in the same TileSet have different collision shapes.
Make the Player Collide With Tile Walls
A basic player scene can look like this:
1
2
3
|
Player (CharacterBody2D)
├─ Sprite2D
└─ CollisionShape2D
|
Start with a minimal movement script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
extends CharacterBody2D
@export var speed: float = 200.0
func _physics_process(_delta: float) -> void:
var direction := Input.get_vector(
"move_left",
"move_right",
"move_up",
"move_down"
)
velocity = direction * speed
move_and_slide()
|
As long as the Player collision layer and mask match the physics layer in the TileSet, the player will be blocked by wall tiles.
While running the game, enable:
1
2
|
Debug
→ Visible Collision Shapes
|
This shows the player and wall collision shapes directly, which makes debugging much easier.
Use Three Map Layers
For a first project, use three layers:
1
2
3
4
|
World
├─ Ground
├─ Walls
└─ Decoration
|
Each node is an independent TileMapLayer.
Put these in Ground:
- Grass.
- Dirt.
- Roads.
- Floors.
Usually there is no collision.
Put these in Walls:
- Walls.
- Cliffs.
- Water boundaries.
- Non-walkable rocks.
Usually this layer has collision.
Put these in Decoration:
- Flowers.
- Grass blades.
- Ground cracks.
- Shadows.
Usually there is no collision.
You can use z_index for a simple draw order:
1
2
3
4
|
Ground: 0
Walls: 1
Decoration: 2
Player: 3
|
If you have trees, roofs, or bridge openings that should cover the player, handle that later with Y Sort or by splitting objects into upper and lower parts. Your first map does not need a complex occlusion system.
Use Terrain to Auto-Connect Roads and Walls
If you want the editor to automatically create edges and corners, such as:
- Grass connecting to dirt edges.
- Roads generating corners automatically.
- Walls choosing the correct tile based on neighbors.
- Water generating shorelines.
Use Godot’s Terrain Set.
The basic process is:
- Add a
Terrain Set in the TileSet.
- Choose a matching mode, such as matching by sides and corners.
- Create terrains, such as
Grass, Dirt, and Water.
- Mark the terrain connection positions for each tile.
- Switch the
TileMapLayer to Terrains painting mode.
- Paint the map with the
Connect or Path tool.
Godot will choose straight, corner, and edge tiles based on nearby cells. The official docs also mention two Terrain painting modes: Connect, which is easier to start with, and Path, which gives more manual control for roads and paths.
You do not need Terrain immediately. First draw a small map manually and understand TileSet, TileMapLayer, and collisions. Then learn auto-connection.
Edit Tiles From Code
Assume this scene structure:
You can reference Ground from the World script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
extends Node2D
@onready var ground: TileMapLayer = $Ground
const SOURCE_ID: int = 0
const GRASS_TILE: Vector2i = Vector2i(0, 0)
func place_grass(cell: Vector2i) -> void:
ground.set_cell(
cell,
SOURCE_ID,
GRASS_TILE
)
|
Here, cell is a tile map cell coordinate. For example:
1
|
place_grass(Vector2i(5, 3))
|
This places a grass tile at column 5, row 3.
Important: SOURCE_ID and the atlas coordinates in GRASS_TILE must match your actual TileSet. Do not copy the sample values blindly.
Convert Between World Coordinates and Cell Coordinates
Mouse positions are world coordinates, while tile maps use cell coordinates. Usually you first convert to the layer’s local coordinates, then convert to a map cell.
World position to cell coordinate:
1
2
|
var local_position := ground.to_local(get_global_mouse_position())
var cell := ground.local_to_map(local_position)
|
Cell coordinate back to map position:
1
|
var position_in_layer := ground.map_to_local(cell)
|
To place a tile with a mouse click:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
extends Node2D
@onready var ground: TileMapLayer = $Ground
const SOURCE_ID: int = 0
const GRASS_TILE: Vector2i = Vector2i(0, 0)
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
var local_position := ground.to_local(
get_global_mouse_position()
)
var cell := ground.local_to_map(local_position)
ground.set_cell(
cell,
SOURCE_ID,
GRASS_TILE
)
|
To support right-click deletion, use:
1
|
ground.erase_cell(cell)
|
set_cell(), erase_cell(), local_to_map(), and map_to_local() are common TileMapLayer APIs.
Do Not Make Every Chest, Door, or Coin a Plain Tile
These objects are usually not good as plain image tiles:
- Coins.
- Chests.
- Doors that can open.
- NPCs.
- Enemies.
- Teleport points.
- Traps.
- Breakable boxes.
They have scripts, animations, collisions, and signals, so they are usually better as separate scenes.
For example, a coin:
1
2
3
|
Coin (Area2D)
├─ Sprite2D
└─ CollisionShape2D
|
Place it under:
Plain tiles are best for static maps. Objects with behavior are better as independent Scene files. Godot also supports Scene Collection tiles, but for beginners, manually placing independent scenes is easier to understand and debug.
What Codex Can Help With
Codex is good at:
- Writing player movement scripts.
- Reading map cells.
- Procedurally generating maps.
- Randomly painting ground tiles.
- Placing and deleting tiles with the mouse.
- Finding spawn points.
- Reading custom tile data.
- Checking
TileMapLayer API usage.
- Implementing coins, doors, and chests.
You can prompt Codex like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
This is a Godot 4.x project.
Scene structure:
World: Node2D
├─ Ground: TileMapLayer
├─ Walls: TileMapLayer
├─ Objects: Node2D
└─ Player: CharacterBody2D
Please write a script for World:
1. Convert the mouse world position to Ground cell coordinates;
2. Left-click places a grass tile;
3. Right-click clears a tile;
4. SOURCE_ID and atlas coordinates should use @export configuration;
5. Use Godot 4.x TileMapLayer API;
6. Use static types;
7. Do not modify the TileSet or scene node names.
|
Codex is less suitable for:
- Determining the tile size of the source art.
- Visually painting an entire map.
- Fine-tuning Terrain bitmasks.
- Guessing
source_id.
- Guessing atlas coordinates.
- Hand-writing large
.tscn map data.
A better workflow is: you create the TileSet, configure collisions, and paint the map in the Godot editor; Codex writes the map interaction, generation logic, and gameplay scripts around the real node structure.
First Practice Project
For the first exercise, make only a 20 × 15 map:
- Paint grass on
Ground.
- Draw a wall border on
Walls.
- Add collision to wall tiles.
- Place a
Player.
- Make the player collide with the walls.
- Add a
Coin scene afterward.
After finishing this exercise, you will understand the basic Godot tile map workflow:
1
2
3
4
5
|
TileSet stores tile art and rules
TileMapLayer draws one map layer
Collision is configured on tiles inside the TileSet
Objects with behavior should be independent scenes
Codex writes scripts around the real node structure
|
Get this minimal map working first. Then move on to Terrain, Y Sort, procedural generation, and large map loading.
Prompts for Generating Godot TileSets with AI
When using AI to generate a Godot tileset, the goal is not to create a pretty map. The goal is to generate a tile atlas that is easy to cut, easy to import into TileSet, and predictable in a grid.
The most important goals are:
- Regular grid.
- Consistent size.
- Seamless repetition.
- No content crossing tile boundaries.
- Easy slicing in Godot.
The prompts below can be copied directly. I recommend starting with the basic ground prompt instead of asking for roads, water, walls, and decorations all at once. AI models are not always reliable with strict tile atlases. The more content you ask for, the easier it is to get misaligned cells, broken connections, or style drift.
Simpler Version for AI Image Models
Generating too many connection tiles at once often fails. For the first attempt, generate only base ground tiles:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
Generate a top-down pixel art tile atlas suitable for Godot 4 TileSet.
Requirements:
- Strict top-down view
- Logical tile size: 32×32
- 6 columns × 3 rows regular grid
- Transparent background
- Every cell has exactly the same size
- No text, no labels, no UI, no characters
- Do not generate a complete map
- Keep style and lighting consistent
First row:
Normal grass, dark grass, sparse grass, dirt, sand, stone ground
Second row:
Fine grass, pebbles, flowers, fallen leaves, ground cracks, small mushrooms
Third row:
Light grass variation, dark dirt variation, wet dirt, mossy stone ground, dry sand, cobblestone ground
Technical requirements:
- All ground tiles must tile seamlessly in all four directions
- Tile edges must not show obvious seams
- Details must not cross into neighboring cells
- Output as a single PNG atlas
|
This version usually has a higher success rate. Generate base ground first, confirm that the style and grid are usable, then continue with roads, water, and walls.
Grass and Dirt Terrain Connection Prompt
This version is suitable for configuring Godot Terrain later:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
Generate a top-down pixel art grass and dirt transition tileset suitable for the Godot 4 Terrain system.
Specifications:
- Logical tile size: 32×32
- Strict top-down view
- Regular grid layout
- Transparent background
- Consistent pixel density
- Consistent lighting direction
- No text, no UI, no characters, no complete scene
Required tiles:
- Pure grass center
- Pure dirt center
- Top edge where grass surrounds dirt
- Bottom edge
- Left edge
- Right edge
- Upper-left outer corner
- Upper-right outer corner
- Lower-left outer corner
- Lower-right outer corner
- Upper-left inner corner
- Upper-right inner corner
- Lower-left inner corner
- Lower-right inner corner
- Narrow horizontal dirt road
- Narrow vertical dirt road
- Cross connection
- T-shaped connection
All edge pixels must match strictly and connect seamlessly.
Do not omit inner corners or outer corners.
Each transition tile must occupy one complete grid cell.
|
This type is the easiest for AI to get wrong. You will often need to fix inner corners, outer corners, and T-junctions manually in Aseprite, Krita, or Photoshop.
Water Tileset Prompt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
Generate a top-down pixel art water tile atlas suitable for Godot 4 TileSet.
Requirements:
- Logical tile size: 32×32
- Regular grid layout
- Transparent background
- Strict top-down view
- Consistent water color and wave style
- No text, no labels, no UI, no complete map
Content:
- Water center
- Water variation tile 1
- Water variation tile 2
- Top shoreline
- Bottom shoreline
- Left shoreline
- Right shoreline
- Upper-left outer corner
- Upper-right outer corner
- Lower-left outer corner
- Lower-right outer corner
- Upper-left inner corner
- Upper-right inner corner
- Lower-left inner corner
- Lower-right inner corner
- Small water ripple
- Floating leaf
- Stone in water
Use natural dirt and a small amount of grass for shorelines.
All edges must connect seamlessly in all four directions.
No tile content may cross its own grid cell boundary.
|
For water assets, check two things carefully:
- Whether the water center tiles seamlessly.
- Whether shorelines and inner/outer corners really connect.
Dungeon Tileset Prompt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
Generate a top-down pixel art dungeon tile atlas suitable for Godot 4.
Specifications:
- Logical tile size: 32×32
- 6 columns × 5 rows regular grid
- Transparent background
- Strict top-down view
- Dark gray stone dungeon style
- Consistent pixel density and lighting direction
- No characters, no complete room, no UI, no text
Content:
- Normal stone floor
- Cracked stone floor
- Mossy stone floor
- Blood-stained stone floor
- Stone wall center
- Stone wall top
- Stone wall left and right edges
- Wall inner corner
- Wall outer corner
- Door opening
- Iron door
- Stone pillar
- Torch base
- Wooden crate
- Wooden barrel
- Rubble
- Bones
- Chains
- Floor trap
All floor tiles must tile seamlessly.
Wall edges and corners must connect correctly.
Every object must stay completely inside its own grid cell.
|
Dungeon assets often fail in one of two ways: walls become side-view objects, or the whole image becomes a complete room. Keep emphasizing “top-down view”, “no complete room”, and “only a tile asset sheet”.
Hand-Drawn Cartoon Style Version
If you do not want pixel art, use this hand-drawn cartoon version:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
Generate a top-down hand-drawn cartoon style tile atlas suitable for Godot 4 TileSet.
Requirements:
- Logical tile size: 64×64
- Strict top-down view
- Soft hand-drawn style
- Clear outlines
- Consistent brush strokes
- Consistent lighting
- Regular grid layout
- Transparent background
- Do not generate a complete map scene
- No text, no UI, no characters
Content:
Grass, dirt, sand, stone path, water, road edges, grass-to-dirt transition edges, small flowers, small stones, grass bushes.
All base ground tiles must tile seamlessly.
Edge patterns must connect with neighboring tiles.
Each tile must remain independent and must not cross into another cell.
|
Hand-drawn style is more likely to produce uneven edges than pixel art. After generation, realign the grid in an image editor before importing into Godot.
Negative Prompts
For models that support negative prompts, add:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
no perspective view,
no isometric view,
no complete map,
no characters,
no text,
no labels,
no UI,
no irregular grid,
no overlapping tiles,
no inconsistent tile sizes,
no borders,
no mockup,
no screenshot,
no realistic photography,
no shadows crossing tile boundaries,
no objects cut off by tile edges
|
Chinese version:
1
2
3
4
|
不要透视,不要等距视角,不要完整地图,不要角色,
不要文字,不要标签,不要 UI,不要预览边框,
不要不规则网格,不要瓦片重叠,不要尺寸不一致,
不要跨格阴影,不要让物体被网格边缘截断。
|
If the model keeps generating a “pretty preview” instead of an asset sheet, strengthen the negative prompt with:
1
2
3
4
5
|
no preview scene,
no game screenshot,
no map mockup,
only a tile atlas,
only separate tiles in a regular grid
|
Practical Generation Settings
Start with these settings:
1
2
3
4
5
|
Logical tile size: 32×32
Atlas layout: 6×4 or 6×5
Final generated image: 1024×1024 or higher
Background: transparent
Style: pixel art
|
One important note: AI models usually will not output a truly strict 32×32 cell grid.
“32×32” mainly tells the model the design proportion. After generation, you still need to use an image editor to:
- Crop the canvas.
- Create a regular grid.
- Realign each tile.
- Scale tiles to true
32×32.
- Fix the edges.
- Export PNG.
For smoother automatic slicing in Godot TileSet, the final atlas should ensure:
- Canvas size is divisible by tile size.
- Every tile sits inside a fixed grid cell.
- No outer border.
- No irregular spacing.
- No content crosses cell boundaries.
The Most Reliable Batch Workflow
Do not generate a full large atlas in one pass. Use this order:
- First image: base ground.
- Second image: road connections.
- Third image: water and shorelines.
- Fourth image: walls and cliffs.
- Fifth image: flowers, grass, and pebble decorations.
For the second batch and later, add this to the prompt:
1
2
|
Keep exactly the same colors, brush strokes, pixel density,
view angle, lighting direction, and outline style as the previous asset set.
|
Even then, different batches may drift in style. For a real project, final color grading and cleanup are usually necessary.
The Version I Recommend Starting With
If you only want to test the Godot TileSet workflow, copy this prompt first:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
Generate a top-down pixel art base ground tile atlas suitable for Godot 4 TileSet.
Logical tile size: 32×32.
Atlas uses a 6 columns × 3 rows regular grid.
Transparent background.
Strict top-down view, no perspective, no isometric angle.
All tiles have exactly the same size and are neatly aligned.
Consistent pixel density, color style, and lighting direction.
First row:
Normal grass, dark grass, light grass, normal dirt, dark dirt, sand.
Second row:
Gray stone ground, mossy stone ground, cobblestone ground, wet dirt, dry grass, gravel ground.
Third row:
Small flower decoration, grass bush decoration, small stone decoration, fallen leaf decoration,
ground crack decoration, small mushroom decoration.
All base ground tiles must tile seamlessly in all four directions.
Decorations must stay completely inside their own tile.
Do not generate a complete map.
No characters.
No text, numbers, labels, UI, borders, or preview notes.
Do not let any pattern cross into neighboring tiles.
Output as a single transparent PNG atlas.
|
This is the best first test asset. If Godot can slice it with a regular grid and the base ground tiles can repeat, it is already good enough. Add roads, water, walls, and decorations later instead of trying to make a complete atlas on the first attempt.
Use AI to Build Complete Scenes from a TileSet
Prompt for Image Generation AI
This is suitable for concept images or visual previews. Upload your tileset as a reference image first, then use this prompt.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
Strictly reference the tileset image I provided. Use only the existing ground, road, water, stone wall, and decoration elements from the tileset to assemble a complete, reasonable forest village scene suitable for a top-down RPG.
Scene specifications:
Strict top-down view.
Do not use perspective or isometric view.
Logical map size: 24×18 tiles.
Logical tile size: 32×32.
Preserve the original art style, colors, textures, lighting direction, and proportions of the reference tileset.
Do not redesign the tiles.
Do not add buildings, characters, or large objects that are not present in the reference image.
Do not generate UI, text, borders, or grid lines.
Output a complete scene, not a tileset atlas.
Map structure:
Use normal grass as the main base layer, mixed with a small amount of dark grass and sparse grass to avoid large fully repetitive areas.
Place a clear entrance at the bottom center of the map.
Build a vertical main road from the entrance to the center of the map.
At the center, split the main road into left and right branches. All roads must connect. Do not create broken roads or meaningless road fragments.
Place a natural-looking small pond in the upper-right area.
The pond must be assembled correctly from water center tiles, top/bottom/left/right edges, and corners. Do not create abruptly cut water or shorelines facing the wrong direction.
Place a connected stone wall area in the upper-left region.
Wall edges and corners must connect correctly.
Keep at least one walkable tile between the pond, walls, and the map border.
Leave a relatively open activity area in the center for character movement.
Do not let the pond or walls completely block the main road.
Decoration rules:
Small flowers mainly appear on grass, not on roads or water.
Small stones may appear sparingly on dirt, road edges, or sparse grass.
Grass bushes are concentrated near map edges, the pond, and wall corners.
Tree stumps should appear only sparingly as visual points of interest, and must not block the main road.
Ground cracks appear only on dirt or dry areas.
Fallen leaves are concentrated near map corners and walls.
Keep the middle of roads clean. Put most decorations on both sides of roads.
Use fewer decorations near the map center and denser decorations near the edges.
Do not decorate every cell. Leave natural empty space.
Reasonableness requirements:
All roads must have a clear purpose and connect to each other.
All walkable areas must be reachable from the entrance.
Water, walls, and roads must connect in the correct direction.
Do not create isolated single water tiles, isolated wall tiles, or incorrect corners.
Do not create tiny enclosed spaces that cannot be entered.
The map should feel like a deliberately designed game level, not random tile placement.
The composition needs hierarchy: the entrance guides the player in, the main road leads to the center, and the pond and wall area act as secondary visual focal points.
Only generate one complete top-down map scene.
|
This prompt pushes the image model to think about structure first instead of pure decoration. But even if you write “strictly reference the tileset,” an image model may still redraw tile details. It cannot guarantee pixel-perfect reuse.
If you need a map that can be imported into a game, do not rely only on the generated image.
Ask AI to Output the Map Layout First
This is better for map reasonableness. Ask AI to avoid drawing and output a 24×18 character map first. After that, let Codex or a script convert the characters into TileMapLayer.set_cell() calls.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
Design a 24×18 top-down RPG forest map layout using the rules below.
Map symbols:
G = normal grass
D = dark grass
S = sparse grass
R = road
W = water
A = stone wall
F = small flower
K = small stone
B = grass bush
U = tree stump
C = ground crack
L = fallen leaves
P = player entrance
Design requirements:
P is located at the bottom center of the map.
There must be a road starting from P and leading to the center of the map.
The road splits into left and right branches near the center. All roads must connect.
Place a natural-looking pond of about 4×5 tiles in the upper-right area.
Place a reasonably connected stone wall segment in the upper-left area.
Keep at least a 7×5 open activity area in the center.
Keep at least one walkable tile between the pond, walls, and map border.
The player must be able to reach all main roads and open areas from P.
Do not create enclosed single-tile grass areas.
Do not create meaningless single-tile fragments of roads, water, or walls.
Decorations must not block main roads.
Use more decorations near the map edges and fewer near the center.
Small flowers can only appear on grass.
Ground cracks can only appear on dirt or sparse grass.
Fallen leaves mainly appear near corners and walls.
Keep the overall map natural, not perfectly symmetrical, but structurally clear.
Output requirements:
First section: output only the complete 24×18 character grid.
Each row must contain exactly 24 characters.
There must be exactly 18 rows.
Second section: list the entrance coordinate, road nodes, pond range, and wall range.
Third section: check whether the map has broken roads, enclosed areas, or unreachable areas.
Do not generate an image.
|
After getting the layout, ask AI to self-check it:
1
2
3
4
5
6
7
8
9
|
Check the character map above:
1. Whether P can reach all R road tiles;
2. Whether there are isolated W water tiles;
3. Whether there are isolated A wall tiles;
4. Whether any walkable area is blocked by water or walls;
5. Whether every row contains exactly 24 characters;
6. Whether the map has exactly 18 rows.
If you find problems, output a corrected complete 24×18 map.
|
This workflow is closer to level design than direct image generation. Validate structure first, then add visual detail.
Make Codex Strictly Use the Tileset in Godot
This is the most reliable approach because it actually uses tile coordinates from the atlas instead of redrawing.
Use the following prompt in the Codex panel in VS Code. It assumes your Godot project already has TileMapLayer nodes and an imported TileSet.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
This is a Godot 4.x project. I need to create a complete map using the existing TileSet.
Scene structure:
World: Node2D
├─ Ground: TileMapLayer
├─ Roads: TileMapLayer
├─ Water: TileMapLayer
├─ Walls: TileMapLayer
├─ Decorations: TileMapLayer
└─ PlayerSpawn: Marker2D
The tileset atlas has 6 columns × 5 rows. Coordinates are defined as:
First row:
(0,0) normal grass
(1,0) dark grass
(2,0) sparse grass
(3,0) dirt ground
(4,0) stone floor
(5,0) sand ground
Second row:
(0,1) horizontal road
(1,1) vertical road
(2,1) upper-left road corner
(3,1) upper-right road corner
(4,1) lower-left road corner
(5,1) lower-right road corner
Third row:
(0,2) water center
(1,2) water top edge
(2,2) water bottom edge
(3,2) water left edge
(4,2) water right edge
(5,2) water outer corner
Fourth row:
(0,3) stone wall center
(1,3) stone wall top
(2,3) stone wall bottom
(3,3) stone wall left side
(4,3) stone wall right side
(5,3) stone wall corner
Fifth row:
(0,4) small flower
(1,4) small stone
(2,4) grass bush
(3,4) tree stump
(4,4) ground crack
(5,4) fallen leaves
Task:
Create a 24×18 forest village map.
Place the player entrance at the bottom center.
Create a main road from the entrance to the center, then split it into left and right branches.
Create a reasonably connected small pond in the upper-right.
Create a reasonably connected stone wall segment in the upper-left.
Keep the center open.
All roads must connect.
Water and walls must not block the path.
Place decorations mainly near map edges, the pond, and wall corners.
Do not place decorations in the middle of roads.
Do not create isolated water tiles, isolated wall tiles, or wrong-direction corners.
Use @export for source_id.
Use Godot 4 TileMapLayer.set_cell().
Use static types.
Separate map data from drawing logic.
Add map size checks and reachability checks in code.
If the existing tileset is missing tiles required for a connection, do not guess or use wrong tiles. Clearly report what is missing.
First read the current project, scene, and TileSet resource. Confirm the real source_id and atlas coordinates before editing code. Do not assume source_id equals 0.
|
The most important line is:
1
|
First read the current project, scene, and TileSet resource. Confirm the real source_id and atlas coordinates before editing code. Do not assume source_id equals 0.
|
Godot source_id, atlas coordinates, and TileSet Source order may differ from what you expect. If AI guesses, it can write code that runs but paints the wrong tiles.
A Two-Stage Prompt Better Suited for Codex
If the project is already complex, do not ask Codex to do everything in one pass. First ask it to analyze and check without modifying files:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
This is a Godot 4.x project.
Do not modify any files yet.
Please perform these checks:
1. Read the current scene structure;
2. Find all TileMapLayer nodes;
3. Find the TileSet used by each layer;
4. Confirm the real source_id;
5. List which tile each atlas coordinate represents;
6. Decide whether the tileset is sufficient for a 24×18 forest village map;
7. If road, water, or wall connection tiles are missing, list them clearly;
8. Propose the map data structure;
9. Propose the reachability check approach;
10. Do not write code yet.
|
After confirming the analysis, ask it to implement:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Now implement the map generation script.
Requirements:
1. Only modify the World script;
2. Do not modify the TileSet;
3. Do not rename scene nodes;
4. Map size is 24×18;
5. Store map data in arrays or dictionaries;
6. Draw with TileMapLayer.set_cell();
7. Use @export for source_id and key atlas coordinates;
8. Add map size checks;
9. Add road connectivity checks;
10. Add reachability checks from PlayerSpawn to major areas;
11. If a check fails, use push_error() to output the reason;
12. After editing, explain how to test it in Godot.
|
This two-stage method is steadier: first let AI understand the project, then let it edit.
The Most Important Lines
For any generated scene, add these rules:
1
2
3
4
5
6
|
All roads must connect to each other and have a clear purpose.
Do not create isolated single water, wall, or road tiles.
Keep the map center readable and increase decoration density near the edges.
Every major area must be reachable from the player entrance.
Decorations must not block the main traversal route.
Design the map structure first, then add decorations.
|
The last line matters most:
1
|
Structure first, decoration second.
|
Without it, AI often tries to make the scene “look rich” first, then produces messy roads, blocked decorations, and unreachable areas.
Recommended Workflow
The safest workflow is:
- Generate or organize the tileset first.
- Create the
TileSet in Godot and confirm each tile’s atlas coordinates.
- Ask AI to output a character map or JSON layout first.
- Check road connectivity, entrance reachability, water, and walls.
- Ask Codex to convert the layout into
TileMapLayer.set_cell().
- Run it in Godot with collision and debug views enabled.
- Adjust decoration density last.
In one sentence:
Do not ask AI to “draw a beautiful scene” first. Ask it to design the structure first, then let code assemble the map using real tileset coordinates. That way, the result is much more likely to become a usable Godot map instead of just a nice concept image.