Questions tagged [entity-component-system]

For use with the architectural pattern most commonly used in Game Development. The core elements are as follows: Entity: The Entity is a general purpose object. Component: The raw data for one aspect of the object, and how it interacts with the world. System: Each System performs global actions on every Entity that possesses a Component. It is run continuously during execution.

Entity–component–system (ECS)

An ECS follows the Composition over inheritance principle that allows greater flexibility in defining entities where every object in a game's scene is an entity (e.g. enemies, bullets, vehicles, etc.).

Every Entity consists of one or more Components which add additional behavior or functionality. Therefore, the behavior of an Entity can be changed at runtime by adding or removing Components. This eliminates the ambiguity problems of deep and wide inheritance hierarchies that are difficult to understand, maintain and extend. Common ECS approaches are highly compatible and often combined with data-oriented design techniques.

Description lifted from Source Doc:

https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system

Additional Sources:

Examples:

Videos:

Related Topics:

143 questions
322
votes
8 answers

Component based game engine design

I have been looking at game engine design (specifically focused on 2d game engines, but also applicable to 3d games), and am interested in some information on how to go about it. I have heard that many engines are moving to a component based design…
a_m0d
  • 12,034
  • 15
  • 57
  • 79
22
votes
6 answers

Efficient way of matching entities to systems in an entity component system

I'm working on a data-oriented entity component system where component types and system signatures are known at compile-time. An entity is an aggregate of components. Components can be added/removed from entities at run-time. A component is a small…
Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416
10
votes
2 answers

What are the disadvantages of the ECS (Entity-Component-System) architectural pattern, compared to OOP (or other paradigms)?

Because of Unity ECS, I've been reading a lot about ECS lately. There are many obvious advantages to an ECS architecture: ECS is data-oriented: Data tends to be stored linearly, which is the most optimal way for the system to access it. In decent…
7
votes
1 answer

Spliting component in Entity-Component-System demands too much refactoring

I have an existing working C++ game library that use Entity-Component-System (ECS). User of my library would like to create some components e.g. Cat :- class Cat{ public: int hp; float flyPower; }; He can modify hp of every cat by e.g.…
javaLover
  • 6,347
  • 2
  • 22
  • 67
6
votes
2 answers

Designs of an entity component system

I wonder how to implement the fastest version of an entity component system (ECS from now on) in C++. First off, regarding terminology: a Scene is a container for Entities (and Systems in some implementations) a Component is a simple data storage…
user1795160
6
votes
5 answers

Custom heap pre-allocation for entity-component system

I have an OOP entity-component system that currently works like this: // In the component system struct Component { virtual void update() = 0; } struct Entity { bool alive{true}; vector> components; void update() {…
Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416
5
votes
1 answer

Questions about Pure ECS (Entity Component System) and update systems

I have written an ECS but I have some questions about the update phase. (in systems) I have read many articles, but not found references to this sort of problems. In order to have benefits from ECS (cache friendly, for example), they are the…
5
votes
1 answer

How to handle dynamic hierarchical entities in ECS

Here's the analogy: I have an organism which is composed of cells which can be further composed of a medley of attachments. What I have currently is a sort of event chain between child/parents to handle attaching and detaching components (which…
Jugbot
  • 142
  • 1
  • 14
5
votes
2 answers

connect systems with events

Using the Entity-Component-System pattern I want to connect some systems with events. So some systems shouldn't run in a loop, they should just run on demand. Given the example of a Health system a Death system should only run when a component gets…
user10895383
5
votes
1 answer

create performant component pooling for system loops

I'm setting up a really small Entity-Component-System example and have some problems with the component pools. Currently my entities are just IDs (GUIDs) which is fine. Each system has to implement the ISystem interface internal interface…
user10895383
4
votes
0 answers

EnTT: Creating new component-types at runtime, or "tagging" a subgroup of entities?

I'm working in a group project on a small 2D minecraft-like game, applying the Entity Component System design pattern. We're required to use the EnTT framework. We'd like to make it easier to manage blocks by tagging blocks as "belonging" to the…
4
votes
1 answer

Is it possible to base a language around the Entity-Component-System architecture?

I've been toying with the idea of creating an ECS based programming language in my head for a couple of weeks now. However, I'm not quite sure creating a general-purpose language based on ECS is possible. How would data structures be implemented?…
Ghost
  • 163
  • 1
  • 7
3
votes
1 answer

Is there a way to see (and get an Entity from) the world from a rust legion ECS system?

I'm following a rust tutorial that uses the Specs ECS, and I'm trying to implement it using the legion ECS instead. I love legion and everything went smoothly until I faced a problem. I'm not sure how to formulate my question. What I am trying to do…
dvidbruhm
  • 33
  • 3
3
votes
1 answer

What is the 'canonical' or best way of associating components with particular entities in an ECS?

I have seen a large number of different, conflicting suggestions on how to store information in an Entity Component System - some touting "purity" or cache optimization, without much explanation. As a general summary: A list of entities, which…
Ethan McTague
  • 2,236
  • 3
  • 21
  • 53
3
votes
2 answers

Why is it possible to modify a static const variable that is declared inside a function?

I'm implementing an ECS framework for my game engine and investigating ways to identify component types at runtime. This means I can dynamically group components of a similar type contiguously in memory. For example, I can have two separate arrays…
SirBob
  • 33
  • 1
  • 7
1
2 3
9 10