13 votes
Accepted

Should I implement Entity Component System in all my projects?

Short version: no, your job as an engineer is to evaluate all applicable solutions to problems before choosing a solution Long Version: "ECS" is an overloaded term. It had a somewhat clear ...
user avatar
11 votes
Accepted

How do I define a required component on a Unity game object?

Applying the RequireComponent decoration to a script will ensure that the GameObject has the specified component. If the component is missing: Unity will attempt ...
user avatar
  • 3,782
11 votes
Accepted

Updating a multithreaded Entity-Component-System

The simple version: don't. One could argue that you have perhaps a slight misunderstandings about how to build an ECS (why would you sent a list of Entity* to a system to update? the System is ...
user avatar
10 votes

Would it be better to use XML/JSON/Text or a database to store game content?

Im late to the party here but I spent A-LOT of time researching this. First why I don't use the following: XML: Excessively verbose. Tons of redundancy. Repeating field names? GROSS JSON: I think ...
user avatar
  • 233
10 votes
Accepted

Creating a Static function inside my class to handle small housekeeping tasks

In C#, having an instance (non-static) method in a class does not copy the instructions for each object created from that class. Static or not, the data that represents the instructions only exist in ...
user avatar
10 votes
Accepted

A more data oriented design approach to Entity Component System game engine

What's an object? What we call an object or an entity depending on the model is, fundamentally, made of two parts: data, and behaviour. Game objects have properties and do things. Let's take a ...
user avatar
  • 1,148
9 votes

Complex system-component dependencies in entity-component-system?

First, you should not have a strict 1-1 mapping of Components to Systems. It's unclear to me from your question if that's the case already. You may very well have singular systems that use or interact ...
user avatar
8 votes
Accepted

How do components access one another in a component based entity system

Components are just a collection of data and logic. How you store and relate them to the logical entity is where you gain or lose performance depending on the strategy you choose. My example and ...
user avatar
  • 1,740
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
  • 113k
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
  • 113k
6 votes

Component oriented programming for rich RPG world

Taking the example of the guitar: (...) a player you can, for example, not only play on guitar as a Musical Instrument, but use it as a Weapon or, what is perhaps more unobvious, throw it right to ...
user avatar
  • 18.5k
6 votes
Accepted

What is a faster alternative to a GetComponent from a RaycastHit?

You could use a Dictionary. Store all Transforms as a key with reference to each Car. In this example, we have a god Game class that holds references to all Cars. (just make sure your Script ...
user avatar
5 votes
Accepted

Entity/Component System and UI "Entities"

After using several entity-component systems, especially CraftyJS, I more or less got the answer to my question: yes, you can reuse components (especially sprites or images and mouse-click handlers in ...
user avatar
  • 11.3k
5 votes
Accepted

How to manage state in a component-based game engine?

It's OK to have component dependencies. And the more explicit the dependency the better. There's nothing worse than dependencies hidden behind useless layers of indirections. Your case doesn't look ...
user avatar
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 ...
user avatar
  • 29.1k
5 votes
Accepted

How to react properly to component field changes?

I personally would go with the event sending, because it's more explicit and easier to follow in code. Something like: ...
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
  • 113k
4 votes

How does this data oriented design retain level data, while still offering cache-wise benefits?

Processing data in arrays is not component based or data driven design. Component based design is about aggregation and dynamic composition. Much of the hype about component performance in the indie ...
user avatar
  • 1,768
4 votes
Accepted

Who Handles Collision in a Component Based Entity System

I'll try to explain with an example: Let's say we have an RPG where you can enchant your weapons with elemental damage. The weapon still have a "physical" attack power, which is reduced by the ...
user avatar
  • 344
4 votes
Accepted

Access Entities components via the Entity that holds them, or via a separate System?

I would recommend having both. Entity/Component Graph This defines which entities are attached to which components. In my engine, there is no such thing as an "entity", but any component can have ...
user avatar
  • 3,567
4 votes

How can I support component-to-object communication safely and with cache-friendly component storage?

Being 'cache friendly' is a preoccupation big games have. This seems to be premature optimization to me. One way to solve this without being 'cache friendly' would be to create your object on the ...
user avatar
  • 15.5k
4 votes

How do components access one another in a component based entity system

Your component entity system doesn't match that which was shown in the article. The article doesn't attach logic components to entities, it uses system objects which look for data components. ...
user avatar
  • 1,663
4 votes
Accepted

How to make a component solution in Godot (similar to Unity's)

A component solution For convenience, not necessary for functionality, let us export an "archetype" variable: export(Array, GDScript) var archetype:Array ...
user avatar
  • 18.5k
3 votes

How do I define a required component on a Unity game object?

Unity has built in functionality for this called RequireComponent. Used like this in Unityscript: ...
user avatar
  • 72.7k
3 votes
Accepted

How to cleanly serialize/de serialize a Dictionary whose values are of a derived class using c# newtonsoft json

After a few hours of work I found I could create a custom converter by extending JsonConverter. I used this answer to help me out. I got my output to look like: ...
user avatar
  • 181
3 votes
Accepted

How should an object that uses composition set its composed components?

Ideally, your Object should have no explicit reference to its components: IUpdater, IDrawable...
user avatar
3 votes

How should IDs be assigned in an entity component system?

A little late to the party here but thought I'd add a few suggestions and reasoning behind each which should be considered when considering these or other suggested answers mentioned in this thread. I'...
user avatar
3 votes

Client-Server Game Communication (w/ Protobuf, Relevancy and Delta Compression)

My solution has been to combine both 1 and 2 into a "watching me list" on each object. When adding a client to an object's list, it sends a full state packet. Then on each update, it can send a delta ...
user avatar

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