Book Image

Creating an RTS Game in Unity 2023

By : Bruno Cicanci
4.5 (2)
Book Image

Creating an RTS Game in Unity 2023

4.5 (2)
By: Bruno Cicanci

Overview of this book

Building a successful real-time strategy game is challenging, because of both the complex mechanics and the need to strike a balance between different elements, ensuring that players enjoy creating and executing strategies against the game's AI. Creating an RTS Game in Unity 2023 will teach you how to install and set up the Unity game engine, create a new 3D project, and build a level editor to make it easier to modify and add maps to a game. The RTS game will start to take shape while you learn to implement different core systems such as melee and ranged battles, unit spawners, camera controls, dynamic mapping generation, basic enemy AI, and the pathfinder algorithm. You'll also get to grips with implementing command units to perform actions, crafting and producing resources, basic physics and collision detection, and building an RTS game from scratch using C# and the latest features of the Unity game engine. By the end of this book, you’ll be able to make professional and high-quality end-to-end RTS games using the best practices and techniques from the gaming industry.
Table of Contents (23 chapters)
Part 1: Foundations of RTS Games
Part 2: The Combat Units
Part 3: The Battlefield
Part 4: The Gameplay

Defending with towers

The Defense Tower is a powerful unit that is placed as a building but can attack enemies that are within its range. This is great when defending the base while sending units to explore the map and is a must-have feature for any RTS game.

We are going to reuse many different scripts and GameObjects to add the Defense Tower as a new unit. This section also works as a guide in case you want to add different units to the game later.

Adding the Tower model

We need to import a new asset package from the Unity Asset Store to include a Tower 3D model and Prefab in our project. Go through the following instructions to add the Canon Tower package to your assets and view it in Package Manager so you can import it into the project:

  1. Open the link (you might need to log in to your Unity Asset Store account created in Chapter 2).
  2. In the list of assets, find the one called Canon Tower and...