New answers tagged

1

There is another performance-related aspect of ECS: parallelization. During the update cycle, each system writes to the limited set of components, often just 1. The components that are not being written at that moment may be safely shared across the multiple threads, which allows multiple systems to run in parallel. Garbage-collected language may be even ...


6

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 you use for your components (and references to your systems, if that makes sense in your implementation). Those containers will likely hold arrays of components,...


2

The performance cost of garbage-collection can be greatly reduced by avoiding the creation of garbage. Garbage is created whenever you create a short-living object. Like in this example: foreach (var thing in veryLargeCollection) { new ConsoleOutputter(new ThingFormatter(new ThingReader(thing).Read()).Format()).Write(); } Each loop iteration will ...


0

AppDomain The most established and bulletproof method for plugin isolation is to use AppDomain. Anything allocated withing one AppDomain will be disposed together when AppDomain unloads or reloads. As a downside, communication between domains (the default and isolated one) is tricky, because it requires serialization and deserialization, which may lead to ...


0

Flat update loop The multi-phase design may be the root of the problem, because it creates a dependency graph of its own, misaligned to ECS's dependency graph. The most direct solution would be to express the phases as a single ECS update. If certain update function needs to be called multiple times (i.e. in different phases) during the update loop, you can ...


0

There are lots of ways to structure an Unity project. There are no right or wrong ways, just ways which work or don't work for you. But personally I am a fan of the single responsibility principle. This principle interpreted in the context of Unity scripting would mean that each MonoBehaviour should be responsible for one thing the object it's on does. Unity ...


1

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. Contigious array of "entities" allocated in a centrally located memory buffer. Naughty Dog uses scenario 1. An entity in this context is just a collection of ...


1

Component-per-buff may cause some serious performance issues. Of course, at this point we can only speculate about the performance, but so far I can only see the downsides — at least in comparison to a more traditional approach. Some of the the major arguments for using ECS stem from it's ability to exploit cache locality and parallelism for the performance ...


2

The idiomatic way of using Unity is that your should not separate your game architecture into models, views and controllers. A gameObject should contain its own data, logic and presentation, distributed among multiple MonoBehaviours, where each behaviour represents a single functionality of that gameObject. And when you have data which is shared between ...


Top 50 recent answers are included