Real-time strategy (RTS)
site/media/lessons/capstones-batch.lesson.ts (5 steps) The rts example (examples/rts/) is a top-down real-time
strategy demo: an orthographic isometric camera, box/click unit selection, and navmesh crowd
pathfinding.
Controls
Section titled “Controls”- WASD / Arrow keys — pan the camera. Scroll — zoom.
- Left box-drag — select units; left-click — select a single unit.
- Right-click — issue a move order to the selected units.
Run it
Section titled “Run it”-
Open the RTS scene. Run
VGAI_PROJECT=examples/rts npm run dev— the project’s scene loads by default.
The isometric RTS view. -
Enter play mode. Press Play — the
RTSDirectorbuilds the navmesh and crowd.
Play mode. -
Marquee-select units by dragging. Drag a box over units to select them; the HUD shows the selection count.
The box-drag selection gesture. -
Right-click to command the selected units to move. Right-click is the move-order button: selected units path to the clicked position via the navmesh crowd, steering around each other. (Left-click and box-drag are for selection only.)
Right-click is the move-order button (units path via the navmesh crowd). -
Stop play mode. Press Stop (or
Escape).
How it works
Section titled “How it works”Units are prefab instances declared in the scene, each carrying an RTSUnit
GameComponent. After load, the example attaches one RTSDirector to a scene-root group; the
director builds the navmesh + crowd at runtime, gives each unit a crowd agent, and owns
the footstep audio + move-marker fade. The isometric orthographic camera is a
scene-declared camera entity carrying an RTSCamera component that owns the WASD/arrow
ground-plane pan (its fixed framing is authored transform data in the scene file). Box/click
selection, right-click move orders, wheel-zoom, and HUD are wired in setup() as runtime
infrastructure.
Recap
New functionality
- Ran the RTS with its orthographic isometric camera
- Used the control scheme: WASD pan, box-drag select, right-click move orders
New concepts & skills
- Units are prefab instances with an RTSUnit component
- An RTSDirector builds the navmesh + crowd at runtime
- A crowd adds avoidance on top of pathfinding
- Move orders are right-click; selection is left-click / box-drag
Next lesson → Manual: Navigation