RTS (Real-Time Strategy) is a video game genre in which players build and manage an empire, army, or other entities in real-time, as opposed to turn-based strategy games. In RTS games, players usually gather resources, construct buildings, create units, and direct their armies in combat, while competing against human or AI opponents.
Prerequisite: This tutorial series assumes that you are familiar with Godot engine & GDScript, although the techniques can be applied to any game engine, such as Unity & Unreal Engine. If you are just starting game development & have no prior experience in Godot engine, I suggest you start here (for 2d) & here (for 3d), and gradually build concepts until you start understanding this series of posts on RTS game development.
RTS Game Breakdown
I will gradually build the game in a series of posts. While developing, I discovered some drawbacks in my approach, that I’ll tell along the way.
How to Make RTS Game Camera System
Full tutorial: How to Make an RTS Camera System
In an RTS game, such as Stronghold Crusader, Age of Empires, and so on, the camera is typically placed above the map. The view is top-down & we can view everything by moving our mouse in that direction.
Making a Procedural Game World for our RTS Game
Full tutorial: Making a Procedurally Generated Level for RTS Game
I made procedurally generated map for this game. The map is made in chunks, and y-axis values of vertices are displaced using Perlin noise. Thus it forms uneven surface of terrain. Water is placed at y=0.0
. I applied a splat map shader to render sand texture for beaches, grass & another kind of sand for rest of the terrain.
Raycast System
Full tutorial: Making Raycast System for RTS Game
Not limited to RTS game only, it is a useful helper that is required in tons of games. To query/use ray-cast in 3D games for various tasks such as selection, getting world position where mouse is clicked & so on. It is a global module that is singleton and accessible everywhere.
Making a Navigation System for Path finding
- First approach: Using Godot’s Built-in navigation system for path finding.
- Second approach: Making our own navigation system using A-star algorithm. Here I defined a graph & applied A-star algorithm on it. I used Godot’s built-in
AStar3D
helper to achieve this. This approach was more suited to the dynamic world I was working on as it gives more control over the navigation system.
Making an RTS Unit that Moves
Full tutorial: Making an RTS Unit that Moves
Our unit consists of a character that has animations for walk, idle & attack are made by artist. In our code, I used the above defined navigation system to move the character in the map.
Making a Selection Box and Selection System
Full tutorial: Making Selection Box in Godot
My implementation uses Godot’s built-in groups to achieve selection. I found that groups are a great way to do many things.
Implementing State Management System to make Units Better
Full post: Making State Machine for Units in RTS Game
The generic unit is sufficient for basic movement and very basic states. For more specialized states, we need a well defined state system for creating complex units.
Making a Health Bar and Health System
Full tutorial: Making a Health Bar & Health Effects in Godot
Our unit must have health, this is helpful specially when we will make army/soldier which can reduce the health of another units. Health system includes:
- health bar
- health value
- effect of health on unit
- states such as dying & died. And queue free.
Making Army unit that Fights
Full post: How to make RTS military unit
We extend the base unit to make a soldier, that has fighting and chasing states as well. We will use health-system to inflict damage. Once health is reduced to zero, the health system handles the death.
Making Marching Formations for RTS Units
Full post: How to Make Marching Formation for RTS Units
Army units, once multiple selected follow a marching path. Approaches such as steering behaviors or hard calculation of offsets. Steering behaviors can be implemented as combination of ray casting and math functions to loosely calculate vicinity in different directions.
Making Buildings in RTS Game
Full tutorial: Making Buildings in RTS Game
we are making generic buildings and their extended specialized buildings, such as huts, town center and so on. later buildings will help in resource management and unit creation.
Making Resource Management in RTS Game
Full tutorial: Making Resource Management in RTS Game
I will make resource objects, and their attributes such as gather rate and so on. And the town center building with stockpile will be made to store the resources.
Making a Villager RTS Unit that Collects Resources
Full post: Making a Villager RTS Unit that Collects Resources
We will make villager unit that will be capable of collecting the resources and bringing it to town center.
Making Building Placement System in RTS Game
Full tutorial: How to place buildings in RTS game
This building placement system will use Raycast system and resource management system to place the buildings that satisfy the constraints of their required resources. The a-star graph in navigation system will be modified to remove those points in graph which are now inside the building. For this, building will have a plain mesh or collision shape to decide the area that needs to be cleared.
Mini-map or Radar for 3D Game
Full tutorial: Making a simple mini map in Godot
By Using 2nd camera to render from top-down perspective. And using different environment or post processing shaders to make it stylized (optional).
Ideas to make units avoid colliding each other (dynamic navigation)
It is not feasible to change A-star graph on runtime for hundreds of units. One approach is to minimize dynamic collisions by allowing units to cross through each other. But if it is not desirable, you can make use of steering behavior to steer around an obstacle, thus it creates a local navigation system. The path finding navigation remains same, we just add more abilities to the unit to steer around locally occurring obstacles. But this approach too, has its limitations, as some units will still collide as they both attempt to steer away.
More Things
- Stats calculation using metrics like army strength, stockpile items values (economic values of every item), and so on.
- Team/alliance system using Groups. Any item that is present in same group will not hit each other. All units or buildings listen to their current group value and change their flags or colors based on their alliance groups.
Downloading the Assets
Assets are taken from different sources. They have CC-BY-3.0, CC-BY-4.0 or CC0 licenses. I am linking to the asset pages here to give them credit & to allow the reader to download those assets and use in their creation.
- https://immunitys.itch.io/diablo-like-hud
- https://opengameart.org/content/enemy-health-bars
- “Fir Tree Stylized” (https://skfb.ly/6UrU6) by AnnaBelle Fibonacci is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
- https://visionsmind.itch.io/highlands-fantasy-pack-3d
- https://www.reddit.com/r/gamedev/comments/jtg3ru/i_made_6_animated_rpg_characters_you_can_use_for/?rdt=47749
- https://shikashipx.itch.io/shikashis-fantasy-icons-pack
- https://freestylized.com/ground/
- https://opengameart.org/content/tree-24
- https://srtoasty.itch.io/ui-assets-pack-2