Expert blueprint for real-time strategy games including unit selection (drag box, shift-add), command systems (move, attack, gather), pathfinding (NavigationAgent2D with RVO avoidance), fog of war (SubViewport mask shader), resource economy (gather/build loop), and AI opponents (behavior trees, utility AI). Use for base-building RTS or tactical combat games. Trigger keywords: RTS, unit_selection, command_system, fog_of_war, pathfinding_RVO, resource_economy, command_queue.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
The command stays on one line. Scroll horizontally to inspect it before copying.
Prefer a local copy? Download the files currently available to SkillsMP.
File Explorer
20 files
Showing SKILL.md
SKILL.md
Source instructions ยท Read-only preview
More from this repository
name
godot-genre-rts
description
Expert blueprint for real-time strategy games including unit selection (drag box, shift-add), command systems (move, attack, gather), pathfinding (NavigationAgent2D with RVO avoidance), fog of war (SubViewport mask shader), resource economy (gather/build loop), and AI opponents (behavior trees, utility AI). Use for base-building RTS or tactical combat games. Trigger keywords: RTS, unit_selection, command_system, fog_of_war, pathfinding_RVO, resource_economy, command_queue.
NEVER Do (Expert Anti-Patterns)
Unit Logic & Pathfinding
NEVER allow pathfinding "Jitter" when moving group units; strictly stagger path queries and enable RVO Avoidance only when units are in motion to save CPU cycles.
NEVER update RVO avoidance every frame for all units; strictly use Avoidance Threading (Project Settings) and replace static units with NavigationObstacle.
NEVER let units get stuck in infinite path loops; strictly implement a timeout and IDLE state if a destination is unreachable.
NEVER use _process() on hundreds of individual units; strictly use a central UnitManager or _physics_process only when required.
NEVER calculate unit visibility manually for Fog of War; strictly use a Shader-based mask (SubViewport + ColorRect) for GPU efficiency.
NEVER process unit AI or pathfinding synchronously for mass groups; strictly offload to WorkerThreadPool and stagger path updates.
NEVER use high-poly visual meshes as NavMesh source geometry; strictly use simplified Collision Shapes for baking.
Interaction & Commands
NEVER forget Command Queuing (Shift-Click); strictly store an Array[Command] and implement a "Force Move/Attack" bypass.
NEVER create excessive micromanagement; strictly automate low-level tasks like auto-aggro range and auto-return for resource gathering.
NEVER use exact floating-point equality (==) for grid or timers; strictly use is_equal_approx() for deterministic triggers.
NEVER rely on the visual SceneTree for selection data; strictly maintain a Typed Selection Set of RefCounted or Resource objects for deterministic serialization and netcode.
NEVER forget Command Queuing; strictly implement a Command Pattern using serializable Dictionary or JSON states for save-game and multiplayer playback.
NEVER forget to duplicate_deep() globally shared Resources; otherwise, modifying one unit's data (e.g., stats) affects all.
Performance & Simulation
NEVER render thousands of units using separate MeshInstance3D nodes; strictly use MultiMeshInstance with INSTANCE_CUSTOM data to drive unique GPU-side state animations (walking/attacking/color).
NEVER calculate transforms for mass units on the main thread; strictly use WorkerThreadPool to push buffers to RenderingServer.multimesh_set_buffer().
NEVER update every unit's navigation path in the same frame; strictly use random timers to stagger updates.
NEVER use standard Strings for high-frequency AI state identifiers; strictly use StringName (&"harvesting") for pointer-speed comparisons.
NEVER allow simulation coordinates to exceed 8192 units without float-precision management; strictly use world-origin shifts.
NEVER use CSGShape3D for building placement ghosts; strictly use optimized static ArrayMesh geometry.
๐ Expert Components (scripts/)
MANDATORY: Read the script for the workflow you are implementing โ do not re-inline selection/fog recipes in the agent body.
Stagger path queries; RVO only while moving; static โ NavigationObstacle; central commander
Still node visuals; pool path queries
+ rts_path_query_pool.gd, rts_army_manager.gd, Batch 09 COM formation
> ~400 / thousands
Server sim: logical transforms on WorkerThreadPool; few NavigationServer map queries (COM / squads), not one agent per soldier
MultiMeshInstance + INSTANCE_CUSTOM; push buffers off main thread
rts_army_manager.gd + MultiMesh path in Batch 09; Do NOT Load per-unit _process agents
Rule: Keep NavigationAgent+RVO while units need individual collision avoidance and micromanage feel. Switch to MultiMesh + server-side transforms when draw-call/node cost dominates โ path as squads, not as thousands of agents.
MANDATORY: rts_unit.gd for Idle/Move/Attack/Hold + NavigationAgent. Deep state graphs โ godot-state-machine-advanced. Always duplicate_deep() shared stat Resources (rts_unit_stat_duplicator.gd).
3. Group Movement & Formations
Avoid clumping on one click target: compute center of mass, apply relative offsets, issue per-unit destinations. For hundreds of units, use one NavigationServer path for the COM (Batch 09) plus rts_group_commander.gd / rts_path_query_pool.gd.
4. Fog of War
MANDATORY for tile/grid fog: fog_of_war_tile_mask.gd. SubViewport mask + shader overlay is valid for soft vision โ implement via docs (Using Viewports) + godot-shaders-basics; Do NOT paste long fog shaders into this skill body when the tile-mask script covers the grid path.
Key Mechanics Implementation
Command Queue
Shift-click chains: store Array of serializable commands; pop on finish; draw queued path lines. Pair with selection scripts' issue-command hooks.
Resource Gathering
ResourceNode โ work timer โ DropoffPoint โ bank update. Wire bank through global_economy_manager.gd / godot-economy-system.
Common Pitfalls
Pathfinding jitter โ Enable RVO; call set_velocity + move on velocity_computed; stagger group path queries.
Too much micro โ Auto-aggro / auto-return gather; command queue for force-move/attack.
Node explosion โ Past a few hundred units, follow the decision tree (MultiMesh + army manager), not per-unit _process.
Godot-Specific Tips
Avoidance: NavigationAgent* RVO requires set_velocity() + velocity_computed for the actual move.
Server architecture: Central UnitManager / rts_army_manager.gd for 100+ units.
Groups: Units, Buildings, Resources for selection filters.
๐ Elite Technical Implementations (Batch 09)
1. Center-of-Mass Formation Movement
For large selections, one NavigationServer path from COM โ target, then offset each unit (see decision tree). Keep the algorithm in project code or formation helpers; pair with rts_path_query_pool.gd so path objects are pooled.
# Sketch only โ prefer pooled queries from rts_path_query_pool.gd
static func move_group_to_target(units: Array, target: Vector3, map_rid: RID) -> void:
if units.is_empty():
return
var com := Vector3.ZERO
for u in units:
com += u.global_position
com /= units.size()
var path: PackedVector3Array = NavigationServer3D.map_get_path(map_rid, com, target, true)
if path.is_empty():
return
var dest: Vector3 = path[path.size() - 1]
for u in units:
u.set_movement_target(dest + (u.global_position - com))
2. MultiMesh armies (when decision tree says so)
Pre-allocate instance_count, drive visible_instance_count, push transforms (optionally via WorkerThreadPool โ RenderingServer.multimesh_set_buffer). No per-soldier MeshInstance3D. See Official Documentation โ Using MultiMesh.
3. Fog โ script first
Prefer fog_of_war_tile_mask.gd. SubViewport vision masks: docs + godot-shaders-basics (do not duplicate long shader bodies here).
MANDATORY for depth beyond decision trees and script catalog: rts-mass-army-deep.md. Do NOT Load on first-pass wiring โ use bundled scripts/ first.
Reference
Progressive disclosure: open Official Documentation links only when researching a specific API;
load Related Skills when routing work to a peer domain โ do not preload the whole lattice.
Official Documentation
Navigation (tutorial index) โ Entry map for agents, servers, meshes, layers, and obstacles before wiring army movement.
Using NavigationAgents โ set_velocity / velocity_computed RVO loop that stops crowd jitter and stuck IDLE timeouts.
Using NavigationServers โ Direct map path queries for center-of-mass formation moves without per-unit agent spam.