CodeBlanks Logo Icon CodeBlanks

What is ECS?

Learn the Entity Component System architecture.

What Is ECS?

Entity Component System (ECS) is an architecture that separates game objects into data and behavior. An Entity represents an object, a Component stores its data, and a System processes that data. This separation makes it easier to manage large numbers of game objects.

Entity: Player
Components:
  Position
  Health
  Speed

An Entity belongs to an Archetype group based on its combination of Components.

The Relationship Between Entity and Archetype

An Entity does not carry game object data by itself; that data is stored in Component elements. Entities with the same combination of Components are grouped under the same Archetype. For example, two Entities with Position and Health components can belong to the same group.

Archetype A:
  Position
  Health

Archetype B:
  Position
  Speed

When the Component combination changes, an Entity can move to a different Archetype group.

Practice Print ECS Concepts to the Console

Create a MonoBehaviour class named ECSIntroduction. In the Start method, print the three core concepts of ECS architecture separately to the console: Entity, Component, and System.

Starter code

Player.cs
using UnityEngine;

public class ECSIntroduction : MonoBehaviour
{
    void Start()
    {
        // Üç ECS kavramını ayrı ayrı yazdır
    }
}

Sample solution

Player.cs
using UnityEngine;

public class ECSIntroduction : MonoBehaviour
{
    void Start()
    {
        Debug.Log("Entity");
        Debug.Log("Component");
        Debug.Log("System");
    }
}

Expected output

Entity
Component
System

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which core concept represents a game object in ECS architecture?

  • System
  • Entity Correct answer
  • Archetype
  • Compiler

Explanation: An Entity represents the identity of a game object in ECS architecture. Its data is stored in Component elements.

2 Identify Entity Components

Question
Entity: Enemy
Components:
  Position
  ____
Answer
Entity: Enemy
Components:
  Position
  Health

Explanation: Health is a data component that the Enemy Entity can have.

3 ECS Architecture Concepts

Term Meaning
Entity Represents the identity of a game object
Component Stores data belonging to an object
System Processes component data
Archetype Defines a component combination

All lessons in Expert