I've got a background in C++ but completely new to game dev, Unreal, and ECS.

Recently, I learned about ECS and fell in love with the resulting project structure and theoretical reduction of spaghetti code that could arise as a game project grows. However, Unreal (or most other mainstream engines) have limited or no ECS systems ready to go. As a result, I decided to try to implement what I like to call a Pseudo-ECS on my own within an Unreal project that lets Unreal handle basics like rendering and physics, and the Pseudo-ECS will handle all gameplay logic.

It's similar to a true ECS system in terms of separation of data and logic, however it does not follow the ECS memory layout, entity id lookups, or even querying for that matter. Here's how it's set up:

All components/systems are derived from these 2 ActorComponent classes and live in their respective folders:

enter image description here

When an ECS_Component is added/removed from an actor in the world, that actor is stored in a global queue for the next frame to process.

enter image description here

Every tick, the global queue is processed against a list of registered ECS_Systems and then cleared. Essentially, ApplySystems will be called on every actor that had a change to the ECS_Components that were applied to it.

enter image description here

ApplySystems checks the required ECS_Components for each ECS_System (using a set of 4 int64 bitflags & bitmasks, supporting up to 255 components) and if the actor has those components, then that ECS_System is added/removed from it.

The function is a bit too big to post here. Basically, it loops through all the components on the actor and generates a bitflagged set of int64's. Then it loops through every system in the game and checks via bitmask to see if the actor should use the system.

enter image description here

The result; all system logic only runs on actors that have the required components. When a component is added/removed, the actor gets updated to ensure it has the right systems at all times. And this works! I successfully created basic health, hunger, and follow systems with this.

Here's the thing... obviously, I would be missing out on any performance gains from a true ECS system, however performance is not what drew me to ECS in the first place. That being said, I don't want this system to be a hindrance to the games performance either.

My question is, do you think this Pseudo-ECS system is worth using even without a true ECS memory layout or querying system? I really have no frame of reference to know this...

  • 1
    \$\begingroup\$ If it works in your testing and has adequate performance on your target devices, that is all that matters. I don't recommend basing your technology decisions on an opinion poll of Internet strangers. Some rando could log on here and say this is the best idea ever, or the worst of all time, and neither of those would change the real evidence that you have access to: your profiling results, and your personal experience of how well you enjoy developing in this system. \$\endgroup\$
    – DMGregory
    Apr 15, 2022 at 11:39
  • 2
    \$\begingroup\$ Sure, but that would require finishing my game first. The question comes down to, what are the effects/drawbacks of an ECS system without ECS-style memory layout and are they generally prohibitive? Someone with a deeper knowledge of unreal and ECS I would listen to more so than myself at this early stage of development. \$\endgroup\$
    – mrg95
    Apr 15, 2022 at 18:54


You must log in to answer this question.

Browse other questions tagged .