Cube colour codes:

  • Blue: selectable and movable unit/object.
  • Red: selectable building.
  • Grey: static obstacle – these objects are baked into the navmesh.
  • Yellow: dynamic obstacle – these objects can be moved, they have their own physics and the navmesh adapts to their changes.

I’ve been dabbling in RTS systems in my spare time.
If the camera is scrolling, it’s because the mouse isn’t in the window, as I’m about to explain. Click anywhere but on the game window to stop the scrolling.


  • Buildings can be selected and used to create units via the command bar.
  • Units can be individually selected or selected as a group.
  • Clicking and dragging displays a selection box. Left clicking the terrain deselects whatever is selected.
  • All units and buildings that are selectable display information about themselves in the UI.
  • All units and buildings have their own health bar that gets bigger or smaller depending on how far the object is from the camera.
  • Health bars are managed in a singe dedicated Canvas.
  • Camera can be moved with the arrow keys or by mousing to the edge of the screen.
  • Camera movement uses acceleration to move so it moves faster over time.
  • Camera adjusts its height depending on the terrain. Height changes are smoothed out so that the height changes are smooth.

Possible future updates:

  • Multiple unit selection. Done!
  • Camera zoom in/out.
  • Camera rotation.
  • Spawn units from a building. Done!
  • Rally point for the unit to move to once it’s created from a building.

I’m really happy with the functionality of the project, now that drag selecting works perfectly and buildings have their own production queues to create units. One of the main issues I had was with the physics raycasting. Physics raycasts go straight through the UI, which obviously isn’t a desirable thing. Since Unity introduced their latest UI implementation (uGUI), the UI is no longer considered a physics layer (the legacy UI is still considered, but I’m not using it). I had to figure out how the new UI’s event systems worked and once I got my head around that, I was able to do a specific uGUI raycast where I it would check if the UI was hit. If it wasn’t hit, it would continue and to the physics raycasting. Fun stuff!

Leave a Reply

Your email address will not be published. Required fields are marked *