Lesson Goal
Lessons 4 and 5 gave you combat that worked in a tiny arena.
This lesson replaces the empty box with a real blockout: floors you can walk on, walls that block movement, and optional navigation so enemies path around corners instead of sliding into sprites.
By the end of this lesson, you will:
- author a TileSet from a sprite atlas or simple placeholder tiles
- paint a multi-layer level (ground, props, collision clarity)
- align physics layers and masks with your player and enemy
CharacterBody2Dnodes - optionally bake NavigationRegion2D geometry that matches walkable floor
Step 1 - Pick Blockout Rules Before Art
Decide three numbers and write them in your design notes:
- Tile size in pixels (for example 16 or 32). Everything snaps to this grid for the blockout pass.
- Player collision shape size relative to one tile (can the player fit through a one-tile-wide corridor?).
- Which layer owns combat collisions (usually ground + walls on one physics layer, triggers on another).
Changing tile size late is expensive. Lock it for the blockout milestone.
Step 2 - Create a Minimal TileSet
- Add a TileMap node to your test level scene (Godot 4.x uses a TileMap root with one or more TileMapLayer children depending on your exact version—use the built-in wizard if the editor offers it).
- In the TileMap inspector, create or assign a TileSet resource.
- Add an Atlas source that points at a strip or sheet of placeholder tiles (solid color tiles are fine).
- Define at least:
- floor tile (walkable)
- wall tile (blocking)
Mini task:
Paint a 20x12 rectangle of floor surrounded by a one-tile wall border. You should feel slight friction when tuning corridors later.
Step 3 - Add Collision to Wall Tiles
Open the TileSet editor, select the wall tile, and add a physics polygon or rectangle that fills the cell.
Common mistake:
Forgetting to enable the collision shape on the tile. If the player walks through walls, check the TileSet collision tab first, not the CharacterBody2D code.
Match collision to Project Settings → Layer Names → 2D Physics so layer 1 might be world and layer 2 player_hurtbox. Document your table in README.md for the team.
Step 4 - Use Multiple Layers for Readability
Split painting across layers such as:
Ground- base walkable tilesDecor- non-colliding details (optional)Walls- colliding tiles or overlay props
Keeping walls on their own layer makes it easier to hide them when debugging navigation or to export tile data later.
Step 5 - Align Player and Enemy Masks
Open your player scene from Lesson 4:
- Ensure the collision_layer includes the layer your floor detector or body expects.
- Ensure collision_mask includes the world layer used by wall tiles.
Apply the same discipline to enemies. If enemies clip through walls, their mask probably does not include the world layer.
Pro tip:
Temporarily enable Visible Collision Shapes under the Debug menu to verify tile collisions line up with art.
Step 6 - NavigationRegion2D (Optional but Recommended)
If you want Lesson 5 chase AI to respect corridors:
- Add a NavigationRegion2D sibling near your level root.
- Use a NavigationPolygon that covers walkable floor, or use Godot’s tools to bake from geometry (exact menu text varies by minor version—search the editor for Bake NavigationPolygon if needed).
- Confirm your enemy script uses navigation when in
CHASE(for exampleNavigationAgent2Dor manual path queries).
If navigation feels like too much for one night, skip baking and leave a TODO comment. The tilemap still wins you real encounter space.
Step 7 - Blockout an Encounter Room
Build one combat pocket inside your larger map:
- two choke points
- one open area for dodge practice
- one partial cover wall (half-height if you support it, or full tile pillar)
Drop your player spawn and two enemy spawns. Playtest until:
- players cannot clip out of bounds
- enemies cannot get stuck on single-pixel ledges (fix tile collision edges)
Troubleshooting
- Player stuck in floor:
collision_maskincludes floor layer but floor tiles also have redundant shapes; remove duplicate polygons. - Jitter on seams: enable Snap Options when painting; verify atlas margins in TileSet.
- Enemies walk through walls: navigation mesh includes walls, or enemy mask missing world layer.
- Tiles render under player: adjust Z Index or layer ordering on TileMapLayer vs character sprites.
Common Mistakes to Avoid
- painting final art before collision is fun to play
- one giant TileMapLayer for everything with no plan for parallax or lighting passes later
- mismatch between tile size and sprite pixels per unit on characters
Mini Challenge
Add a hazard tile (pit or spikes) on a dedicated physics layer that only the player hurtbox detects. Wire it to the same apply_hit path you used in Lesson 4 so damage feels consistent.
FAQ
Should I use autotiling now?
Optional for blockout. Add autotile rules once the layout is approved.
What about isometric?
This lesson assumes orthogonal maps. Isometric changes sorting and collision; postpone unless your pitch demands it.
Can I use TileMap for a Metroidvania room graph?
Yes, but plan room scenes as separate instances. This course keeps one continuous test map for speed.
Quick Recap
You now have:
- a TileSet-backed level with explicit wall collision
- layer discipline for ground versus blocking tiles
- collision masks aligned with combat characters
- a path toward navigation-aware AI
Next, you will add quest and dialogue scaffolding so the blockout supports objectives instead of pure skirmishes. Continue to Lesson 7: Quest and Dialogue Systems.
For deeper tile tooling, work through Tilemap Basics in the Godot guide in parallel.
Bookmark this lesson before you invite playtesters into the map—they will find every collision bug you hid in the empty arena.