Creating an RTS in Unity: Part I

Update: This can now also be found at, where the entire tutorial is now being hosted.

This forms the beginning of a series of tutorials on building an RTS in Unity 3D. I will be using the free version of Unity 4.0 for Windows with C# scripting. There will be a lot of programming, so it is assumed that you have an understanding of basic programming principles and at least a basic familiarity with either C# or a similar language (e.g. Java, C++). I will be covering why we are doing things a certain way, but I won’t be stopping to discuss any language stuff in detail. It is also assumed that you have a basic knowledge of Unity – as much as is covered in the beginners tutorials anyway. Earlier posts will include a bit more detail on Unity (including some screenshots), but as we progress this will diminish.

All of the source code will be freely available on my github account. I will make a commit for each post, so you will be able to step through the revision history alongside each post. This will include the Unity project as well as the source code.


The goal is to produce a  game that includes all of the core mechanics needed to play a modern real-time strategy game. The core features we will be aiming for are:

  • Multiple players, one of which will be controlled by the player
  • Selection of game objects – whether units, buildings, or resources
  • The ability to issue commands to any units / buildings that the player controls
  • The ability to create new units from specified buildings
  • The ability for specified units to be able to construct new buildings
  • The ability to collect resources, thus enabling a simple economy
  • An interactive display that shows the player
    • What resources they currently have
    • What game object they have selected
    • What options a selected game object has
  • A functional menu system
  • The ability to save and load games

Obviously this is no light undertaking. Just looking at that list is daunting … but it is entirely possible. I will attempt to keep things as short as possible, but I do not wish to skimp on any of the necessary details either. As we progress I will also attempt to lay out my reasoning for certain design decisions. So, it is time to begin …


The first thing to do is download and install Unity 3D, if you have not already done so, which can be found here. I do not believe it matters which platform you use, but I am using Windows 7. If you have any trouble using another platform, I apologize in advance. Once you have installed Unity, tweak the layout of the interface to fit your preferences. The areas that are important to be able to see are

  • Project view
  • Hierarchy
  • Inspector
  • Scene view
  • Game view

It can also be useful to see the console output as well, though we will not be using it in these tutorials. But when developing it is useful to be able to print out debugging information to the console while you are play-testing.

Now that you have installed Unity, it is time to create a new project for our game. (File -> New Project …) I will call it RTS Tutorial, but you are free to give it any name you choose. By default (on Windows, at least) Unity will put this under MyDocuments, but it is easy enough to change this when you are creating the project. Do not worry about adding any extra packages at this stage.

When we create a new project Unity presents us with an empty scene that contains a camera. The first thing we want to do is to save this scene. (File -> Save Scene) Let’s call this scene Map since we will be using it to play around with a map for most of the project. Once you have hit save you should see the scene file called map now located in the Assets folder for your project.

First Objects

The last thing I want to cover this time is actually being able to see something happening, otherwise most of this post is just boring overview. Let’s add some ground for things to sit on and a cube to give us a point of reference.

For the ground we will create a plane and rename it Ground. (Game Object -> Create Other -> Plane) Let’s set it’s position to (0,0,0) and it’s scale to (100,1,100). This will make the centre of our ground to be the origin and it will extend 100 units in either direction. Note that we are using the y-axis for height off the ground. This will be the case for everything in our world.

Ground Settings

Ground Settings

Now create a cube (Game Object -> Create Other -> Cube), position it at (0,2,0), and set the scale to (10,4,10). The centre of all objects is in the middle of the volume, so to sit an object on the ground we must move it up (in they-axis) by half of it’s height (the y-value of it’s scale).

Cube Settings

Cube Settings

At the moment our scene only contains ambient light. This means that our rendered scene will not be black, but we will also not be able to distinguish things like the edges of objects. We can fix that by adding a point light to the scene.  (Game Object -> Create Other -> Point Light) Let’s rename it Sun, since we want it to simulate a sun somewhere at a distance. Position the newly created sun at (100,400,100) so it is off to the side of the centre of our little world and up quite high. Now set the range for the light to be 1000 so that it spreads light across most of the ground.

Sun Settings

Sun Settings

The last thing to do is to position our camera so that we can see our cube. Select the camera and set it’s position to (20,10,-20) and it’s rotation to (15,-45,0).

Camera Settings

Camera Settings

And that is all for part 1. We now have ground that can be extended when we want to, a light to simulate the sun, a cube for reference, and a camera to see things. If you hit play now you should see a scene very similar to the one below.

Final Scene for Part I

Final Scene for Part I

Next time we will look at adding some framework details to build our game on and then we will make our camera interactive.


8 thoughts on “Creating an RTS in Unity: Part I

  1. Kitsune says:

    Do you think you could do a tutorial for those who have unity 3.5? I really like your tutorial and I would like to use it to help me with a project but the computers at our school only have updated to 3.5

    • I don’t see this happening sorry. At the moment I am struggling to find time to continue posting for this tutorial. I simply do not have the time to figure out the differences between Unity 3.5 and Unity 4 and then work out how to port things. If anyone else is interested, feel free to work on that. But I will not be doing so.

  2. Hey!
    I promised myself I would make a RTS in Unity when I got the time. Today I finally started searching for info and work done on the matter , and just stumbled across your tutorial series. So this comment is just to let you know that I will be following them from Part I, and giving you a thanks in advance, for taking the time to make this possible (:

  3. Somebody Anonymous says:

    Please don’t stop this thing. Teach us all there is to know. I beg you don’t quit.
    Also, it’s great that you’re using the latest version. It has the latest features so everybody should be on the same page anyway.

    Thank you and keep it up!

  4. Thank you, I’ve just been searching for info about this subject for ages and yours is the greatest I’ve discovered till now. However, what about the bottom line? Are you sure concerning the source?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s