New answers tagged

1

You are looking for an alternative to dependency injection. I'll offer you a perspective shift: The game world is external. You are just sending and receiving messages. It is not a great idea to have a dependency on something external that you can't control. Wait. We are making games. And a game is a piece of software, it isn't a portal to another world. Or ...


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

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 ...


Top 50 recent answers are included