11 votes

What is a pure ECS?

A pure Entity - Component - System architecture means that: Every object in your game is an Entity. However, an entity itself has neither any data nor any code. It is an abstract concept not ...
user avatar
  • 112k
8 votes
Accepted

How could I implement an ECS in C?

As a pattern ECS and data oriented programming in general are closer to pure C than C++. Entity component systems consist of three major elements. Components are simply holding data; they shouldn't ...
user avatar
  • 667
8 votes
Accepted

Dealing with more complex entities in an ECS architecture

Games typically approach this type of issue using a transformation hierarchy. In this model, each entity can be treated as a "child" of a "parent" entity. The entity's local ...
user avatar
  • 115k
8 votes
Accepted

Unity Hybrid ECS with "old way"

It is perfectly possible to mix both styles. The same GameObject can have some of its functionality implemented with the new ECS system and other functionality in classic MonoBehaviour events. What ...
user avatar
  • 112k
7 votes
Accepted

What should be an entity/component, and what shouldn't?

A lot of systems in a game that needs to be updated are things that are not rendered and don't need any input, they simply need a call to their update function every frame. They don't have any ...
user avatar
  • 115k
6 votes
Accepted

Is an ECS viable in garbage collected languages?

The Garbage Collector (GC) is not really an obstacle to implement an Entity-Component-System (ECS) architecture. All you need is a root object for your ECS. It would hold references to the containers ...
user avatar
  • 18.9k
6 votes
Accepted

Is it a good idea to use a hash table in an ECS?

If you want to know what is faster, measure. That is the engineering approach. Thus, write your code in a way that you can swap the implementation (e.g. behind an interface) and benchmark. With a ...
user avatar
  • 18.9k
5 votes
Accepted

How to implement n-body in an Entity Component System

One nice thing about systems in an ECS architecture is that they don't all necessarily need to follow the same structure of ...
user avatar
  • 112k
5 votes

Fastest way to look up an entity with a set of components?

The way ECS implementations like the new one in Unity work is to use the concept of Archetypes. An Archetype is the description of the components in a particular entity. Given sets of components, ...
user avatar
5 votes

Should components in Entity Component System pattern have logic?

I was considering voting to close this question as opinion-based, but I think there are a couple of misunderstandings about Entity-Component Systems and Data-Oriented Design here that are worth ...
user avatar
  • 115k
5 votes

I don't get why ECS is considered more performant than OOP

With an OOP architecture, you usually end up with code which if unrolled to a purely procedural style would look like this: ...
user avatar
  • 112k
4 votes
Accepted

Handling input in a custom ECS engine

I think you're pretty close. Here is one option, which I'd try to implement first. You need 2 components Input Camera I ...
user avatar
  • 15.7k
4 votes
Accepted

Entity Component System: where do I put containers?

Update I have wrote Theraot.ECS inspired by Fastest way to look up an entity with a set of components?. However this answer motivated me to allow to specify custom containers for particular types. ...
user avatar
  • 18.9k
4 votes

Entity Component System: where do I put containers?

Just like with any software architecture question, the short answer is "It depends..." Where do I put that quadtree? Any auxiliary data structures needed by one system only should be part of that ...
user avatar
  • 112k
4 votes

What is a pure ECS?

Here's an article explaining it quite clearly: https://www.gamedev.net/articles/programming/general-and-gameplay-programming/understanding-component-entity-systems-r3013/. A component can be likened ...
user avatar
  • 166
4 votes

Is it a good idea to use a hash table in an ECS?

I'd agree with Panda Pajama's advice: How about you start with what you think makes the most sense, and build from there? Optimizing too early for a very specific use case may end up backfiring -- at ...
user avatar
  • 115k
4 votes
Accepted

Unity DOTS/ECS: Spawning entity programmatically at specific location

After you instantiate the entity, try: ...
user avatar
  • 733
3 votes
Accepted

Unity conversion of Gameobjects to ECS

Its look like that you have not installed the "Hybrid Renderer" Package. When you want to convert Game objects to Entities then you have to also install "Hybrid Renderer" from package manager. ...
user avatar
  • 1,117
3 votes

How do I build the dependency graph on ECS?

Make a Immovable component that contains a set※1. The idea is that when this set is empty the entity can move. We can do this by having The ...
user avatar
  • 18.9k
3 votes
Accepted

Should fields in components in an ECS use polymorphism?

feels like I'm violating the ECS rule There is no ECS police that will come and put you in ECS Jail. This is your architecture, you set it up how it fits your needs. having any functionality in ...
user avatar
  • 15.7k
3 votes

How can I handle scripting-like tasks in my ECS?

I'd recommend solving this in pretty much the usual way: with a scripting language. (This could be a text-based language like LUA, a nodegraph based visual scripting tool, pre-digested bytecode, etc.) ...
user avatar
  • 115k
3 votes
Accepted

How does ECS handle systems which need to know more about the environment of the entities it processes?

My solution to this would be to create a component AITarget which marks an entity as something zombies are supposed to attack (like a player or a civilian). Now ...
user avatar
  • 112k
2 votes
Accepted

How do the systems find the entities they should operate on in Entity-Component-System pattern?

There are a couple of ways, and they will depend on the implementation of the rest of your system. Here are a few of those I've seen. You could manually tell the system(s) that a new component of a ...
user avatar
  • 15.7k
2 votes
Accepted

Fastest way to look up an entity with a set of components?

Update I have wrote Theraot.ECS inspired by this answer. It allows you to use Guid, int or whatever for the entities. It will ...
user avatar
  • 18.9k
2 votes
Accepted

Intellisence doesn't show the ECS API Summaries

Apparently, this is not something that Unity supports at this time. However, there's a workaround by one of the Unity users in the forum. Turning this: into this: 1) Go to: ...
user avatar
  • 1,126
2 votes

How do I build the dependency graph on ECS?

Entity movement can be influenced by a variety of sources such as local player, network, or even AI so this is why I often find it easier to treat it as state that is mutated across multiple systems. ...
user avatar
  • 1,997
2 votes
Accepted

Where should I put units and items in a squad-combat ECS-based game?

As a general disclaimer and as DMGregory already stated it: The rules of ECS are not written in stone. Doing it on way has benefits, doing it another way has some others. So, you need to know, what ...
user avatar
  • 1,312
2 votes

Is it useful to distinguish between two different kinds of events?

A common solution to free systems from having to process every single event is by using a subscription architecture. Individual systems can subscribe to specific types of events. The event dispatcher ...
user avatar
  • 112k
2 votes

Component instance reference in Unreal Engine 4

To do this in Unreal C++, inside the CPP file you need to do the following: Make sure to include the header component: #include "Camera/CameraComponent.h" Then in the class constructor: ...
user avatar
  • 975

Only top scored, non community-wiki answers of a minimum length are eligible