Skip to content

Real-time strategy (RTS)

capstone lesson Advanced ⏱ 20 min vgai 0.1.0

Prerequisites: Foundations · Manual — Navigation & pathfinding

What you'll learn

  • Run the RTS example with its isometric camera
  • Select units with a box-drag
  • Understand how a runtime navmesh + crowd moves units to ordered positions

What you'll build: A top-down RTS with selectable units that path around via a navmesh crowd.

Walkthrough — Real-time strategy (RTS) · generated by site/media/lessons/capstones-batch.lesson.ts (5 steps)

The rts example (packages/editor/template/src/examples/rts/) is a top-down real-time strategy demo: an orthographic isometric camera, box/click unit selection, and navmesh crowd pathfinding.

  • WASD / Arrow keys — pan the camera (edge-pan too).
  • Left box-drag — select units; left-click — select a single unit.
  • Right-click — issue a move order to the selected units.
  1. Open the RTS scene. Load examples/scenes/rts.vscn.json.

    The RTS scene loaded with the isometric camera
    The isometric RTS view.
  2. Enter play mode. Press Play — the RTSDirector builds the navmesh and crowd.

    The RTS running in play mode
    Play mode.
  3. Marquee-select units by dragging. Drag a box over units to select them; the HUD shows the selection count.

    Dragging a selection box across the RTS units
    The box-drag selection gesture.
  4. 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.)

    The RTS in play mode after a right-click in the world
    Right-click is the move-order button (units path via the navmesh crowd).
  5. Stop play mode. Press Stop (or Escape).

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 and gives each unit a crowd agent. The orthographic iso camera, edge/WASD pan, box/click selection, right-click move orders, audio, 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