Inheritance vs Entity Component System

The research statement has been fully justified. Therefore I have started looking into different architectures or practices that are common among many game engines. Specifically looking at Unity and Unreal they have both adopted these types to allow users to easily develop software for games.

Inheritance is a modular approach where you can directly inherit base classes into what they call sub classes. These sub classes have all of the functionality from the base class and either override or expand them further. This allows for the code to be reusable and very dynamic in many cases. You can create an array of elements with the base class type while additionally adding any of the sub-class that inherits the base classes functionality, data etc. This allows data to be structured and well represented in a list so that objects with only certain elements will be manipulated to do things that a base class desires.

However there are some major pitfalls in regards to inheritance that the Entity Component System design pattern tends to solve. Rather than having a large overhead the entity component system ensures that there is a more data driven structure present. The data driven design approach enables a different structure that is much more efficient in regards to thousands of objects rendered in a scene. The functionality present in inheritance is more discrete for an entity component system. Entity is simply a container for the identification of an object while the component solely serves for data in a container. This data is then manipulate in a system where it iterates through all entities with a given component or archetype. An Archetype being a package or a group of components identified by a prefix so that allows for defining special types of entities.

Research will be done further to prove the limits of inheritance versus the entity component system. Both practices are used among both engines but what is a better design practice in the end? or are they meant fundamentally different and used for distinct purposes that aren’t related?

Over the next couple of weeks I hope to answer this question myself. With doing thorough testing from either using a custom made engine or using the systems that unity and unreal engines have provide to create such design practices.

Add a Comment

Your email address will not be published. Required fields are marked *