Unity ECS

Unity ECS Tutorial | Making a Survival Shooter Game, Part 1 – Introduction & Setup

In part 1 of this Unity tutorial series we’ll learn how to setup Unity ECS in your project.

Welcome to part 1 of this Unity tutorial series where we’ll be creating a survival shooter game using Unity’s new implementation of the Entity-Component-System pattern, or Unity ECS for short.

This first part will introduce what we’ll be working on and go over how to setup Unity ECS.

What You’ll Learn From This Series

As of early 2018, Unity ECS is still in it’s infancy. It’s available in all 2018 TECH stream releases as a feature that’s in “preview” mode.

Because of this, much of the code you’ll see throughout this series will be subject to change. So I want you to focus on learning the higher level concepts of the Entity-Component-System pattern instead.

The Entity-Component-System pattern follows the Composition Over Inheritance Principle. The idea is that your objects gain certain behaviors based on the data components that they have, rather than the classes that they inherit from.

So instead of worrying too much about the specifics of the code, try to pay close attention to the way the logic is structured. Learning to think in terms of data and behavior will be the theme of this series.

As we create our survival shooter game, you’ll really want to focus on how we take the mechanics and break them down into logical domains that’ll consists of components and systems. Speaking of which, let’s take a look at what we’ll be making before we setup Unity ECS.

What We’ll Be Making

We’ll be making a run-of-the-mill survival shooter game that’ll look familiar if you’ve ever checked out Unity’s official tutorials.

The mechanics are simple: the player moves around the environment and can shoot his weapon. Enemies randomly spawn and move towards the player, attacking him when they’re in range.

The player gains point for each enemy that he kills and dies when his health reaches zero. And that’s all there is to it.

As I mentioned before, the mechanics will be separated into logical domains. Each of these domains will consists of data and behavior.

For instance, player movement requires input data that’s provided by the controller. Then a system needs to interpret that data into behavior that takes the form of the player’s avatar moving around the scene.

We’ll apply this same concept to each game mechanic, from the camera following the player to the enemies spawning within the scene.

Alright, let’s setup Unity ECS so we can get started!

How to Setup Unity ECS

There are a few requirements needed in order to start writing Unity ECS code:

  1. Download a version of Unity that supports Unity ECS – I recommend downloading Unity Hub to keep track of multiple Unity installations. You can install Unity 2017 LTS for ongoing projects and the latest 2018.X TECH release to access the latest features.
  2. Set your project’s Scripting Runtime Version to .Net 4.X Equivalent – Unity ECS requires the latest version of the .Net runtime in order to work. This is a win-win because .Net 4.X has some great features that .Net 3.X is missing.
  3. Copy a custom manifest file into your project’s manifest folder – This special manifest file contains references to packages that aren’t listed in the Unity package manager by default. You can download this manifest file here.
  4. (Optional) Dock the Entity Debugger to your editor – The Entity Debugger is an invaluable tool that we will be using frequently throughout this series. I recommend docking it somewhere in your editor.

Download the Project Files for Part 1


Now that we’ve setup Unity ECS for our project we’re ready to go! In part 2 we’ll add the player avatar to the scene and start working on player movement.

The project files will be available for download to all of my Tier 2 Patrons. Becoming a Patron is a great way to access my code and support my content at the same time.

Remember, much of the code we’ll be writing is subject to change due to the fact that Unity ECS is still in preview mode. But the concepts will stay the same. So brush up on the Entity-Component-System pattern, and we’ll continue to focus on the higher level concepts as we implement our game.