Understanding Terminology
In this lesson, we’ll learn about the Entity Component System.
We'll cover the following
What is ECS?
ECS uses a common set of terms to denote its different parts:
-
An entity can be anything: an adventurer, an orc, or a pair of shoes. The game map is an exception; it’s usually not an entity but rather a resource that entities reference to travel. Entities don’t have logic associated with them. They’re little more than an identification number.
-
A component describes a property an entity may have. Entities typically have many components attached to them, serving as a description and adding functionality through systems. For example, a goblin might have a Position component describing where it is on the map, a
Render
component describing how to render it, aMeleeAI
component indicating that it attacks with hand-to-hand combat, and aHealth
component describing how many hit points it has left. A sword might also have aPosition
component describing its location on the map and aRender
component indicating what it looks like. It would differ from the goblin by having anItem
component to indicate that it’s an item. Components don’t have logic associated with them, either. -
Systems query the entities and components and provide one element of game-play/world simulation. For example, a
Render
system might draw everything with aRender
component and aPosition
component onto the map. AMelee
system might handle hand-to-hand combat. Systems provide the game logic that makes the game function. Systems read entity/component data and make changes to them, powering the game’s functions. -
Resources are shared data available to multiple systems.
The figure below illustrates the relationship between these terms.
Get hands-on with 1400+ tech skills courses.