DOTS and ECS for the slightly technical person.

A brief overview of when, where, and why to use DOTS and ECS with Unity.

May 19, 2024

With Unity recently announcing Unity 6 and the release of ECS 1.0, there’s been a surge of discussion about DOTS, the readiness of ECS for production, and whether any of it is right for your project. If you find all the technical chatter overwhelming, you’re not alone. In this article, I aim to demystify these technologies. By the end, you should have a clear understanding of DOTS and ECS to help answer your key questions.

What is ECS?

ECS stands for Entity Component System, this is the grand architecture that your programmers must adhere to when using ECS. The caveat is that it is a Data Oriented Programming Pattern (DOP), while most if not all engineers are used to Object Oriented Programming (OOP). So what does that mean? It means your engineers will need to work in an environment that is completely new to them. OOP has been the long standing norm for decades, as it closely mimics how humans view the world. Want to make a car? Its made up of an engine, exhaust, tires, doors, etc. We naturally break objects down into smaller objects. This is OOP. DOP on the other hand is how computers want to use data. It focuses on processing predictable blocks of memory. To accomplish this, code must be structured in a very different manner.

So why should I ever use ECS and DOP?

We will get a bit technical in this section, so hang on!
ECS sets out to solve a core disadvantage of OOP; how CPU’s want to process RAM/Memory. (Read as ongoing sentence) When OOP was first accepted as the standard, the time it took a CPU to fetch a block of memory from RAM was about the same amount of time as adding two numbers (a single CPU instruction). Since then CPU’s have massively improved in their ability to process CPU instructions, but the process of fetching a block of memory has remained relatively slow. How slow? 50–200x slower in some cases! CPU’s have been optimized to read data in a continuous manner. The problem with OOP is that your data is spread out in all your different objects, causing the CPU to have to wait; this waiting is the dreaded Cache Miss. Cache misses occur when the CPU needs some data that was not immediately available. ECS’s goal is to minimize cache missing by optimizing your program for CPU friendly memory access.

So what is DOTS?

DOTS stands for Data Oriented Technology Stack (similar to DOP mentioned above). ECS is actually part of DOTS, and broadly speaking DOTS is all about making your code fast! DOTS contains several improvements that can be used to solve different issues. At its core, DOTS consists of the Burst Compiler, ECS, and the Job System. Each of these are aimed at solving different problems, and all together can massively increase performance in a Unity project!

ECS can easily handle hundreds of thousands of objects

Fast is good, why doesn't everyone use it?

So you heard what its all about, and took away that it makes things go fast, so why shouldn't everyone use it? In most cases projects simply don't need it. ECS sets out to solve a problem of scale. Whether its hundreds of thousands of units, massively complex algorithms like pathfinding, or working with limited computer power, ECS is the easiest solution, and in many cases the only solution in Unity. So if your project has a few hundred units, or normal gameplay, ECS isn't needed. Using the traditional Unity approach is not “outdated” or “old”, it still remains perfectly valid. ECS is posed to solve a very specific set of problems that would other wise be unfeasible with Monobehaviours and OOP.

Considering ECS for your Unity project depends heavily on the scale and complexity of what you’re developing. If your project demands high performance with extensive entities or complex calculations, ECS and DOTS could be game-changers. Remember, while ECS offers significant performance boosts, it requires a steep learning curve and thorough understanding. Evaluate your team’s capability and project’s needs carefully before diving in.

Great you have a project that needs to go fast! What should you know before you get started.

  1. Not everything in Unity supports DOTS. For example, the animation system for DOTS is not complete, as such you will have to use GameObject’s in a hybrid setup
  2. ECS requires deep technical understanding to take full advantage of it, ensure you have a team that is capable of developing for ECS.
  3. Guides, How-To’s, and forum posts are often out dated, and it can be a real learning curve in the beginning.
  4. Your engineers are going to have to get their hands dirty. With all the points above, your engineers need to be ready and capable of solving complex problems with limited resources.
  5. Development is ongoing and releases often introduce many changes. Hopefully this is reduced now that 1.0 is released

Need Developers experienced with DOTS and ECS?

Curious about integrating DOTS and ECS in your project? Let’s explore how DevBuddy can accelerate your development. Contact us today — we’re here to tackle your toughest challenges.

Reach out at: website | projects@devbuddystudio.com.

Ready to bring your projects vision to life?

Don't settle for anything less than exceptional. Click to get started on your journey to high-quality, budget-friendly, and timely game development.