Tech Evangelist LATAM at Unity Technologies - Producer
Preparing the Project and HELLO WORLD
TOWER DEFENSE WITH ECS
This is the start of my new article series about: Creating a full Tower Defense game with ECS (Entity Component System), a new feature from Unity and, believe me, it is awesome.
I will post a new article each week. I will try to cover the project from start to finish (from scratch) but I think it will be better if you have some knowledge of Unity and programming logic already (actually, ECS is a bit more advanced than just starting with programming). I will provide a few links where you can get started on those topics first. And don’t worry, you will be able to read the articles here in my Connect page. Also, next article will have links about more tutorials and where you can really get started about some ECS theory.
Ok: DEV ON!
1) Work environment and Goals
Unity version: 2018.2.0b9 (this may change during our articles).
IDE: Visual Studio or JetBrains Rider
Packs from Asset Store:
- Tower Defense Template
- Unity Particle Pack
Unity Hub 0.18.0 (or later).
Coffee (as much as you need).
Comfortable place to work.
Create a simple tower defense game using at least 5 different towers (upgrade-able).
We will have some different mechanics from normal tower defense games ;)
Enemies will use ECS to spawn and move (for now Hybrid ECS. We will test Pure too probably).
Towers will be from normal Unity Monobehaviour (and so the player mechanics).
Player will have a score system, health system and a coin system (to buy towers and upgrade them).
Save and Load system.
Basic Pooling system for our particle effects.
We may have more features to be added for fun.
2) Preparing the Project
Let’s create a new project. The name of mine will be “UTD ECS” (Unity Tower Defense with ECS) - original, right? I know, I am very creative XD.
After creating your new project, let’s import some packages from our Package Manager. Go to Window, Package Manager and click on All. Install the following packages: Entities, Post-Processing and TextMesh Pro.
And then, download and install the pack “Tower Defense Template” from Asset Store.
It is free and it is a full tutorial from Unity (check it if you want to know a tower defense game, but without ECS, it has more gameplay mechanics than this one probably). While importing, please select only the following folders/files:
Then, download and import one more asset from Asset Store, free and from Unity too: Unity Particle Pack. You can pretty much import all folders from this one.
To make it more organized, I also ordered my folders like the picture below. Feel free to copy or, just keep your own (but remember that I will use mine during the full article series). I like to separate, for small projects, folders for Art, Audio, Animations, Scenes, etc (I also created 3 new folders inside Prefabs).
As for the windows inside the Unity Editor, I like to use a variation from the “Tall” layout. Something like the picture below.
Of course, feel free to choose whatever you like.
Please, get used to the assets and still this week we will create our first assets. This first article was just an introduction and the next ones should be longer. Also, I had a problem with the format here while editing the text.
If you want to get started fully on Unity and about C#, check here for awesome tutorials:
If you don't know too much about C# or Unity, I highly recommend you to take a look there first.