34
votes
Accepted
Improving an O(N^2) function (all entities iterating over all other entities)
I know you do not conceptualize this as collisions, however what you are doing is colliding a circle centered at the creature, with all food.
You really do not want to check food that you know is ...
16
votes
Improving an O(N^2) function (all entities iterating over all other entities)
You should adopt a space partitioning algorithm like BVH to reduce complexity. To be specific to your case, you need to make a tree that consists of axis-aligned bounding boxes that contain food ...
11
votes
Accepted
Event handling in Pure Entity Component Systems, is this approach correct?
Merging systems, such as collision and collision response, is a bad idea. The reason being that there can be many different responses to collisions: Physics based, and game-logic based.
In most game ...
10
votes
Accepted
Understanding Entity Component System
Can Component hold the logic? or it should not and stay as a bag of data?
That's how you like. I suggest to stick with the first implementation and finish your project, then see if it worked out ...
8
votes
Entity Component System: system and components relation
One of the big reasons some ECS proponents favour a strict separation of components and systems is that it helps architect game functionality in a data-oriented style.
In the ideal data-oriented flow,...
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 ...
7
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 ...
5
votes
Accepted
Entity Component System - Handling Input
Input is usually more abstracted from character behaviour than that.
Usually by some kind of "character controller" that translates requested state into movement/actions.
Ideally you don't want to ...
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 ...
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 ...
5
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 ...
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 ...
4
votes
Accepted
How "smart objects" are implemented and actually work?
Well, concerning "The Sims" article you are reffering to that actually could mean a lot of different things. But the core idea as I get it is that each object can expose a list of "...
3
votes
Accepted
ECS - Components inside components?
First of all, there is no "right" or "wrong" way to structure a game's software architecture. Just ways which work or don't work for you.
Usually you wouldn't nest components. What you would do ...
3
votes
Accepted
How do I better organise rendering in an entity component system?
From what I understand from your question, you have:
Two separate systems, 2D and 3D rendering
Each entity has a component describing the data needed for each system to operate
The systems require ...
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 ...
3
votes
ECS: AI components and systems
The problem I see with this approach is that the AI module cannot be easily decoupled from the components attached to the entities. To evaluate a tree or run a state machine, it needs to know ...
3
votes
Should entities auto-register to systems based on their component signature?
I think you may be overthinking this.
The point of ECS is to be simple:
An entity is nothing more than an aggregate of components.
A system is only interested in a subset of those components. For ...
3
votes
Event handling in Pure Entity Component Systems, is this approach correct?
Your question boils down to
Is it a good idea to use a publisher-subscriber-based GUI and to keep this subsystem
distinct from my ECS (while enabling interop between them)?
Yes, keep your UI and ...
3
votes
Integrating Unity physics with Entitas
I literally just started looking at Entitas last night so there may be better solutions, but you could do something like the following:
Create a component to store the collisions
...
3
votes
Accepted
Where is 'game logic' implemented in component based design?
Not everything in your game must be based on the ECS pattern you're using and the game logic might be a good candidate not to.
It could be a global script.
Or, as you mention, you can implement the ...
3
votes
Accepted
Make the components of an ECS polymorphic
Both your possible solutions are unnecessarily complicated or brittle: generally, ill-advised.
Polymorphism
Your question title is
Make the components of an ECS polymorphic
but then you don't ...
3
votes
Accepted
Is there a "Least Terrible Method" for sharing Entities over Network?
Preface: I'm not familiar with Box2D, but these structures can be found in Boost Geometry (R-trees) if you are really interested, as well as other libraries:
Premature Optimization (Don't Do it)
...
3
votes
ECS in MMOs - How to handle IDs for different object types?
I would generally not put entity IDs and type IDs into the same number-space. That just leads to confusion about whether a specific ID refers to an entity type or an unique instance of that type.
...
3
votes
Improving an O(N^2) function (all entities iterating over all other entities)
While the space partition methods described indeed can reduce the time your main problem is not just the lookup. Its the sheer volume of lookups you make that makes your task slow. So your optimizing ...
3
votes
User-friendly scripting when using an ECS?
ECS has its pros and cons. User-friendly scripting is not one of its pros.
The problem ECS solves is the ability to have a large number of similar things in your game at the same time while ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
entity-system × 401component-based × 129
architecture × 104
c++ × 79
entity-component × 79
c# × 33
libgdx × 26
java × 22
entity-component-system × 21
design-patterns × 20
entity × 18
xna × 12
javascript × 12
lua × 12
unity × 11
ai × 11
scripting × 11
collision-detection × 10
optimization × 9
state × 9
game-design × 8
events × 8
rendering × 7
software-engineering × 7
oop × 7