Core Loop
- Prepare: Build/upgrade towers with available currency
- Wave: Enemies spawn and traverse path toward goal
- Defend: Towers auto-target and damage enemies
- Reward: Kills grant currency
- Escalate: Waves increase in difficulty/complexity
NEVER Do (Expert Anti-Patterns)
Design & Strategy
- NEVER make all towers have the same niche; strictly ensure distinct specialties: Aura Slow, Armor Piercing, Anti-Air, Burst Sniper, and Splash Damage.
- NEVER allow a "Death Spiral" with no exit; strictly provide small comeback bonuses or interest on saved gold to prevent early inevitable failure.
- NEVER make early waves feel like busywork; strictly provide an "Early Call" bonus to skip wait times and accelerate engagement.
- NEVER trust client-side economy updates; strictly require the authoritative server to validate currency addition and tower purchases in co-op.
Pathing & Placement
- NEVER allow the player to "Seal" the exit in mazing games; strictly validate path existence with
NavigationServer2D.map_get_path() before finalizing tower placement.
- NEVER use synchronous
bake_navigation_polygon() for mazing; strictly offload to a worker thread to prevent 100ms+ frame hitches during placement.
- NEVER use global coordinates for grid logic; strictly convert to Vector2i/Vector3i to ensure pixel-perfect tower alignment.
- NEVER call
get_overlapping_bodies() every frame; strictly use signals (body_entered/body_exited) to maintain a local target cache.
- NEVER use
_process() for projectile movement if count > 500; strictly use the PhysicsServer2D/3D directly for high-performance bullet-hell tiers.
- NEVER spawn hundreds of projectiles as full Nodes; strictly use Object Pooling to reuse resources and avoid garbage collection stutters.
- NEVER use standard Strings for priorities; strictly use
StringName (&"first", &"strongest") for O(1) hash comparisons in targeting loops.
- NEVER ignore the
progress property on PathFollow nodes; strictly use it as the O(1) way to identify the target closest to exit.
- NEVER process tower search logic every frame; strictly throttle ACQUIRE searches (e.g., every 5-10 frames) to save significant CPU cycles.
- NEVER scale Tower
CollisionShape non-uniformly; strictly adjust the radius property of the Shape resource to preserve collision math.
- NEVER delete enemies immediately on death; strictly use set_deferred("disabled", true) and wait one frame to prevent physics server crashes.
- NEVER hardcode waves in huge switch statements; strictly use Custom Resources (.tres) for clean balancing and sequence editing.
๐ Expert Components (scripts/)
Original Expert Patterns
- wave_manager.gd - Professional wave orchestrator with Resource-based enemy composition and cleanup.
- tower.gd - Base turret class with FSM state management and firing logic.
- tower_targeting_system.gd - Autonomous priority logic (First/Last/Strongest/Weakest) for efficient targeting.
Modular Components
Decision Trees (MANDATORY script reads)
Path style
| Style | Approach | Scripts / APIs |
|---|
| Fixed lanes | Path2D / PathFollow2D progress | wave_manager.gd, wave_resource_spawner.gd |
| Mazing | Seal-check before place | NavigationServer2D.map_get_path / AStarGrid2D (NEVER) |
| Organic curves | Bezier PathFollow progress | Prefer PathFollow over per-frame seek |
Targeting priority
| Priority | Sort key | MANDATORY |
|---|
| FIRST | Highest progress (closest to exit) | tower_targeting_system.gd |
| LAST | Lowest progress | same โ LAST implemented |
| STRONGEST / WEAKEST | health desc / asc | same โ WEAKEST implemented |
Use signal-cached range Area enter/exit + frame-sliced acquire (acquire_interval_frames). Never get_overlapping_bodies() every frame.
Economy
PhysicsServer Projectile Golden Path
When count > ~500:
- MANDATORY tower_defense_patterns.gd
spawn_fast_bullet (PhysicsServer3D kinematic RIDs).
- Pool RIDs; AoE via
intersect_shape; defer collision disable on death.
- Modest counts: homing_projectile_3d.gd / pooled Nodes OK.
Tower FSM
MANDATORY: tower.gd for idle โ acquire โ windup โ fire. Targeting stays in tower_targeting_system.gd.
Deep recipes (on demand)
Reference
Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain โ do not preload the whole lattice.
Official Documentation
- Navigation introduction (2D) โ NavigationRegion2D baking and map queries for mazing TD path validity.
- Using NavigationAgents โ agent path following and avoidance when towers reshape walkable space.
- NavigationServer2D โ
map_get_path seal checks before committing tower placement.
- AStarGrid2D โ integer-grid path probes that simulate build cells without a full nav bake.
- PathFollow2D โ
progress / progress_ratio for fixed-lane enemies and First/Last targeting.
- PathFollow3D โ 3D track followers used by wave spawners and homing aim references.
- Using Area2D โ signal-driven range caches (
body_entered / body_exited) instead of per-frame overlap polls.
- Physics introduction โ layers/masks so tower ranges hit enemies, not other towers or walls.
- Using servers โ PhysicsServer bodies for high-count projectiles without Node overhead.
- Resources โ WaveDefinition
.tres data instead of hard-coded spawn switches.
- Using multiple threads โ WorkerThreadPool / Thread patterns for async navigation rebakes during placement.
- Using TileMaps โ TileMapLayer grids for build cells, paths, and placement snapping.
Prerequisites
Complements
- godot-2d-physics โ Area2D range, layers, and PhysicsServer2D projectile patterns for dense waves.
- godot-state-machine-advanced โ StringName tower FSM states (Idle/Acquire/Attack/Cooldown).
- godot-economy-system โ kill rewards, interest, and early-call income without death spirals.
- godot-combat-system โ damage types, armor pierce, splash, and projectile hit resolution.
- godot-resource-data-patterns โ typed Wave/Tower Resources and
duplicate(true) for balance edits.
- godot-game-loop-waves โ prepare/defend/reward phase orchestration around the spawner.
- godot-signal-architecture โ wave_started / enemy_died / currency_changed buses without frame polling.
- godot-performance-optimization โ pooling, server bodies, and throttled acquire searches under heavy projectile counts.
- godot-monte-carlo-balancer โ sample wave DPS, leak rates, and economy bands before shipping difficulty curves.
Downstream / consumers
Master
- godot-master โ library router and mirrored module entry for cross-skill discovery.