Skip to main content
10 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 ...
DMGregory's user avatar
  • 141k
5 votes
Accepted

Appropriate Cache Friendly Associative Container For An Entity Component System

Do the simplest thing that works, especially early on. If you've ever seen videos of triple-A titles in alpha, you'll know how slow / buggy they are. This is normal; in fact, it's desirable. And it's ...
Engineer's user avatar
  • 30.4k
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 ...
Philipp's user avatar
  • 123k
5 votes
Accepted

Should entities auto-register to systems based on their component signature?

TL;DR Entities SHOULD NOT auto-register to systems based on component signatures; prefer instead to explicitly declare component sets/nodes to register your entities to systems that operate on ...
Danny Yaroslavski's user avatar
4 votes
Accepted

ECS component dependencies / sharing and cache locality

Reducing cache misses doesn't need to mean getting rid of them entirely, so we do need to be wary of "making the perfect the enemy of the good enough" After all, the absolute worst performance your ...
DMGregory's user avatar
  • 141k
3 votes

How to Implement ECS Archetypes in C#?

Here is a sketch of how you can implement an archetype in C#: ...
DMGregory's user avatar
  • 141k
3 votes
Accepted

Implementation details of Command Pattern in conjunction with Entity Component System

How do I populate the execute command if there isn't any logic that "belongs" to an entity? But there is a mechanism for applying logic to an entity: Systems. In ECS, Systems map behavior to ...
Mattia's user avatar
  • 408
2 votes

How to handle Entity Initialisation and Destruction

This is one of the common problems with ECS architecture: Intersystem communication. There is no silver bullet solution, and research is ongoing, but common solutions are: Observer patterns. Any ...
Ian Young's user avatar
  • 2,694
2 votes

Entity Component System: system and components relation

My point is: if the Systems are the ones responsible for the actual game logic update (practically speaking, the game logic code is written inside the system), is there a 1:1 relation between ...
sebas's user avatar
  • 490
2 votes

Pass data down to components

Will you have networking? I understand that you are probably making a single player game engine. However, thinking about how to deal with the network very, very, very early in the desgin will push ...
Theraot's user avatar
  • 28.2k
2 votes
Accepted

Event-Based Entity-Componenty-System

Entity movement is a great example. In most games, they do not care what triggers the movement, only that entities move in a common and standardized way. So the idea is to design some middle-man ...
Naros's user avatar
  • 2,022
2 votes

Appropriate Cache Friendly Associative Container For An Entity Component System

ArcaneEngineer's advice is good, particularly for early development (to an extent - once you configure your engine to work a particular way, it can be significantly hard to rework it later). For ...
metamorphosis's user avatar
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 ...
PSquall's user avatar
  • 1,332
2 votes
Accepted

How to Implement ECS Archetypes in C#?

Those Archetypes are IEnumerable<TComponentKind>, where TComponentKind is what you use to identify components. You can, of ...
Theraot's user avatar
  • 28.2k
2 votes

Implementations for storing entities in an ECS system

Neither of the three approaches are typical. The first approach could be considered a "naive" approach as it works, but is not very efficient because you'd need to check for every entity if it matches ...
Sander Mertens's user avatar
1 vote
Accepted

How do I contiguously store and iterate over ECS components in C++?

Entity component systems store data in one of three ways: Centrally allocated arrays, accessable by all systems. Contigious arrays of subsets of components that each system is interested in. ...
Ian Young's user avatar
  • 2,694
1 vote
Accepted

How do you handle entity life-time and entities without all components in an ECS?

One way this can be solved is with the notion of Archetype. An Archetype is the set of components a particular entity needs. So in your example you have two archetypes: (position, velocity, visible) ...
DMGregory's user avatar
  • 141k
1 vote

Hidden copies of the environment in an entity component system

I presume since you want a system similar to Entt you're writing in C++. Environment Rendering One of the simplest solutions you may find for the rendering system would be a simple boolean property on ...
Hawkeye4040's user avatar
1 vote

Additional Entity ID for networking instead of general EID?

An UUID takes up 128 bits. Your own ID can be as small as ceil(log_2(n)) bits; where n is the number of entities you want to distinguish between. Getting the ...
ratchet freak's user avatar
1 vote

How could I get rid of these shared_ptr/weak_ptr in this entity-component architecture?

If there is a single owner and you can properly handle clearing dangling pointer it is fine to use unique_ptr for the owner and raw pointers for the non-owners. ...
ratchet freak's user avatar
1 vote
Accepted

Implementations for storing entities in an ECS system

Sander's answer mentioned families, and I wanted to add some info: Families group entities together based on component criterion. Usually, a system has one family that forms its entity list. ...
clabe45's user avatar
  • 408
1 vote

How to implement n-body in an Entity Component System

For every matching entity, Gravity will have to walk over all the entities (minus one) to compute the attraction force. The first problem is, how do I efficiently get the relevant entities? A ...
PSquall's user avatar
  • 1,332
1 vote

Use GKEntity's component(ofType:) with inheritance

Well it appears as if no one here seems to know it so I'll just post what I used which is a new method that I added in an extension to GKEntity (which I was ...
lsauceda's user avatar
  • 151
1 vote
Accepted

How to: Duplicating and updating component data in systems

First of all, there is no such thing as a good pure ECS. Every ECS system is different, and all of them have their own advantages and disadvantages. Problem #1 I'd go with the following setup. ...
Smilediver's user avatar
1 vote

Event-Based Entity-Componenty-System

As Naro's said, you need a component for every player, that joins a Guild / Party / Alliance to save the information, that they are in that alliance or whatever. But you most likely need a serverside ...
PSquall's user avatar
  • 1,332
1 vote

How does an ECS work for a world subdivided into chunks (example)?

This answer is focused on how I would approach solving the problem instead of a prebaked specific answer. For google reference, the basic ideas are based on broad phase and narrow phase collision ...
Kal_Torak's user avatar
  • 146
1 vote
Accepted

Entity Component System data duplicate

When you have a large amount of data shared between multiple game entities, then the component representing that data might be a good candidate for the flyweight pattern. Your ...
Philipp's user avatar
  • 123k

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