What Is Entity Component System (ECS) and How to Benefit From It in Unity

Under the hood of ECS and why should you bother making your game efficient

The Problem

In case our ambitions go beyond a regular “clicker” implementation, the focus should be put on the problem of the game architecture extensibility. The more complex and diverse game mechanics, content variety, and possible interactions, the more difficult it is to perform correctly and avoid the so-called “spaghetti code”.

How Does ECS Work?

But there is another interesting approach that is very convenient to apply when developing games — the Entity-Component-System (ECS) pattern. In contrast to the standard approach, while implementing this pattern we are not dealing with specific objects whose behavior is described by the corresponding classes, but with “entities” that themselves do not carry any logic and are rather containers for “components”. The last ones are data warehouses that define the properties of entities with such components.

What are the Benefits of ECS?

When you first start working with the ECS approach, everything seems too complicated. You literally need to rebuild the way of thinking and begin searching for similar object properties, grouping them into components, and creating systems to process them. Once done, you begin to see the game architecture differently.

Is Unity DOTS the Next Step?

It all began to change when Unity realized the advantages and power of the ECS approach when developing games and began to create its own integrated ECS solution. This solution is part of a whole large data-oriented approach developed by Unity, called DOTS. It includes solutions for ECS (Entities), multi-threading (JobSystem), and a suite for compiling highly optimized native code (BurstCompiler).

To Wrap It Up

Unfortunately, we cannot use DOTS as a substitute for all systems in the game yet. As it requires global changes in all other aspects of the game (physics, UI, animations, sounds) for their compatibility with this system. But Unity makes confident steps in this direction. Now we have the opportunity to use DOTS-compatible physics. Pretty soon DOTS-compatible animations will be released. Many other cool systems are also under development.

Originally published at https://www.visartech.com



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Visartech Inc.

A Digital Partner that optimizes IT infrastructure and develops intelligent software solutions and creates interactive experiences. Reach us www.visartech.com