godot-tilemap-mastery
Expert blueprint for TileMapLayer and TileSet systems for efficient 2D level design. Covers terrain autotiling, physics layers, custom data, navigation integration, and runtime manipulation. Use when building grid-based levels OR implementing destructible tiles. Keywords TileMapLayer, TileSet, terrain, autotiling, atlas, physics layer, custom data.
What this skill does
# TileMap Mastery
TileMapLayer grids, TileSet atlases, terrain autotiling, and custom data define efficient 2D level systems.
## Available Scripts
### [tilemap_data_manager.gd](scripts/tilemap_data_manager.gd)
Expert TileMap serialization and chunking manager for large worlds.
### [terrain_path_painter.gd](scripts/terrain_path_painter.gd)
Advanced runtime terrain autotiling (Terrains v2) for roads, rivers, and organic paths.
### [destructible_tile_logic.gd](scripts/destructible_tile_logic.gd)
Pattern for managing tile health and breakage based on Custom Data Layers.
### [gameplay_data_query.gd](scripts/gameplay_data_query.gd)
Efficiently reading Custom Data (friction, hazards) to drive character/physics logic.
### [procedural_chunk_batcher.gd](scripts/procedural_chunk_batcher.gd)
Optimized procedural generation using bulk tile placement logic for better performance.
### [sorting_Z_layering.gd](scripts/sorting_Z_layering.gd)
Handling Y-sorting and Z-index layering for 2.5D effects and multi-floor buildings.
### [physics_shape_interaction.gd](scripts/physics_shape_interaction.gd)
Expert TileMap physics: handling one-way collisions and collision layer management.
### [nav_mesh_teleport_fix.gd](scripts/nav_mesh_teleport_fix.gd)
Runtime navigation updates for dynamic world-shifting and destructible environments.
### [tile_pattern_stamper.gd](scripts/tile_pattern_stamper.gd)
Using `TileMapPattern` for efficiently "stamping" complex, multi-tile structural pieces.
### [fast_metadata_cache.gd](scripts/fast_metadata_cache.gd)
Optimization: caching TileData metadata for high-frequency gameplay queries.
### [tilemap_layer_v43_upgrade.gd](scripts/tilemap_layer_v43_upgrade.gd)
Managing the transition to the Godot 4.3 standard of multiple `TileMapLayer` nodes.
## NEVER Do in TileMaps
- **NEVER use set_cell() in loops without batching** — 1000 tiles × `set_cell()` = 1000 individual function calls = slow. Use `set_cells_terrain_connect()` for bulk OR cache changes, apply once.
- **NEVER forget source_id parameter** — `set_cell(pos, atlas_coords)` without source_id? Wrong overload = crash OR silent failure. Use `set_cell(pos, source_id, atlas_coords)`.
- **NEVER mix tile coordinates with world coordinates** — `set_cell(mouse_position)` without `local_to_map()`? Wrong grid position. ALWAYS convert: `local_to_map(global_pos)`.
- **NEVER skip terrain set configuration** — Manual tile assignment for organic shapes? 100+ tiles for grass patch. Use `set_cells_terrain_connect()` with terrain sets for autotiling.
- **NEVER use TileMap for dynamic entities** — Enemies/pickups as tiles? No signals, physics, scripts. Use Node2D/CharacterBody2D, reserve TileMap for static/destructible geometry.
- **NEVER query get_cell_tile_data() in _physics_process** — Every frame tile data lookup? Performance tank. Cache tile data in dictionary: `tile_cache[pos] = get_cell_tile_data(pos)`.
---
### Step 1: Create TileSet Resource
1. Create a `TileMapLayer` node
2. In Inspector: **TileSet → New TileSet**
3. Click TileSet to open bottom TileSet editor
### Step 2: Add Tile Atlas
1. In TileSet editor: **+ → Atlas**
2. Select your tile sheet texture
3. Configure grid size (e.g., 16x16 pixels per tile)
### Step 3: Add Physics, Collision, Navigation
```gdscript
# Each tile can have:
# - Physics Layer: CollisionShape2D for each tile
# - Terrain: Auto-tiling rules
# - Custom Data: Arbitrary properties
```
**Add collision to tiles:**
1. Select tile in TileSet editor
2. Switch to "Physics" tab
3. Draw collision polygon
## Using TileMapLayer
### Basic Tilemap Setup
```gdscript
extends TileMapLayer
func _ready() -> void:
# Set tile at grid coordinates (x, y)
set_cell(Vector2i(0, 0), 0, Vector2i(0, 0)) # source_id, atlas_coords
# Get tile at coordinates
var atlas_coords := get_cell_atlas_coords(Vector2i(0, 0))
# Clear tile
erase_cell(Vector2i(0, 0))
```
### Runtime Tile Placement
```gdscript
extends TileMapLayer
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.pressed:
var global_pos := get_global_mouse_position()
var tile_pos := local_to_map(global_pos)
# Place grass tile (assuming source_id=0, atlas=(0,0))
set_cell(tile_pos, 0, Vector2i(0, 0))
```
### Flood Fill Pattern
```gdscript
func flood_fill(start_pos: Vector2i, tile_source: int, atlas_coords: Vector2i) -> void:
var cells_to_fill: Array[Vector2i] = [start_pos]
var original_tile := get_cell_atlas_coords(start_pos)
while cells_to_fill.size() > 0:
var current := cells_to_fill.pop_back()
if get_cell_atlas_coords(current) != original_tile:
continue
set_cell(current, tile_source, atlas_coords)
# Add neighbors
for dir in [Vector2i.UP, Vector2i.DOWN, Vector2i.LEFT, Vector2i.RIGHT]:
cells_to_fill.append(current + dir)
```
## Terrain Auto-Tiling
### Setup Terrain Set
1. In TileSet editor: **Terrains** tab
2. Add Terrain Set (e.g., "Ground")
3. Add Terrain (e.g., "Grass", "Dirt")
4. Assign tiles to terrain by painting them
### Use Terrain in Code
```gdscript
extends TileMapLayer
func paint_terrain(start: Vector2i, end: Vector2i, terrain_set: int, terrain: int) -> void:
for x in range(start.x, end.x + 1):
for y in range(start.y, end.y + 1):
set_cells_terrain_connect(
[Vector2i(x, y)],
terrain_set,
terrain,
false # ignore_empty_terrains
)
```
## Multiple Layers Pattern
```gdscript
# Scene structure:
# Node2D (Level)
# ├─ TileMapLayer (Ground)
# ├─ TileMapLayer (Decoration)
# └─ TileMapLayer (Collision)
# Each layer can have different:
# - Rendering order (z_index)
# - Collision layers/masks
# - Modulation (color tint)
```
## Physics Integration
### Enable Physics Layer
1. TileSet editor → **Physics Layers**
2. Add physics layer
3. Assign collision shapes to tiles
**Check collision from code:**
```gdscript
func _physics_process(delta: float) -> void:
# TileMapLayer acts as StaticBody2D
# CharacterBody2D.move_and_slide() automatically detects tilemap collision
pass
```
### One-Way Collision Tiles
```gdscript
# In TileSet physics layer settings:
# - Enable "One Way Collision"
# - Set "One Way Collision Margin"
# Character can jump through from below
```
## Custom Tile Data
### Define Custom Data Layer
1. TileSet editor → **Custom Data Layers**
2. Add property (e.g., "damage_per_second: int")
3. Set value for specific tiles
### Read Custom Data
```gdscript
func get_tile_damage(tile_pos: Vector2i) -> int:
var tile_data := get_cell_tile_data(tile_pos)
if tile_data:
return tile_data.get_custom_data("damage_per_second")
return 0
```
## Performance Optimization
### Use TileMapLayer Groups
```gdscript
# Static geometry: Single large TileMapLayer
# Dynamic tiles: Separate layer for runtime changes
```
### Chunking for Large Worlds
```gdscript
# Split world into multiple TileMapLayer nodes
# Load/unload chunks based on player position
const CHUNK_SIZE := 32
func load_chunk(chunk_coords: Vector2i) -> void:
var chunk_name := "Chunk_%d_%d" % [chunk_coords.x, chunk_coords.y]
var chunk := TileMapLayer.new()
chunk.name = chunk_name
chunk.tile_set = base_tileset
add_child(chunk)
# Load tiles for this chunk...
```
## Navigation Integration
### Setup Navigation Layer
1. TileSet editor → **Navigation Layers**
2. Add navigation layer
3. Paint navigation polygons on tiles
**Use with NavigationAgent2D:**
```gdscript
# Navigation automatically created from TileMap
# NavigationAgent2D.get_next_path_position() works immediately
```
## Best Practices
### 1. Organize TileSet by Purpose
```
TileSet Layers:
- Ground (terrain=grass, dirt, stone)
- Walls (collision + rendering)
- Decoration (no collision, overlay)
```
## Available Scripts
> **MANDRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.