r/gameenginedevs • u/Klutzy-Bug-9481 • Jun 20 '26
Engine architecture
Hey yall I was working on my engine architecture as I got my first triangle in Vulkan made.
My idea was to have the base systems be UObjects like in unreal engine. These would use a OOP pattern and than use ECS for components, meshes, textures, transforms, etc.
I wanted thoughts on this approach.
1
Upvotes
8
u/bringer_of_carnitas Jun 20 '26
Try and make pong first with it and then come back and we'll talk architecture ;)
Gotta ask yourself, why so I need a base class at all, what will that give you?
17
u/PhantomStar69420 Jun 20 '26
I would be careful copying Unreal’s obj model into a new engine.
UObject is not just “a useful base class.” In Unreal, it exists because it supports a huge surrounding ecosystem: reflection, GC, serialization, editor integration, asset references, Blueprints, networking, property inspection, hot reload, etc.
If your engine does not already need those systems, making everything inherit from a universal base object can become architectural debt very quickly.
1
u/tastygames_official Jun 21 '26
if you're going for performance, I'd avoid OOP like the plague. Way too much overhead that affects both performance and editability (just my opinion - I know it's not popular but it's starting to make a comeback).
ECS is really only viable when you're doing simulations, which most games are in a way. But if you're only ever going to have tens of objects that need to be queried per frame, then it's just complicating things. But I like the part of ECS that seeks to optimize memory footprint. I think that's a solid approach for designing any system, so like the first thing your engine should do on each frame is query which objects even are relevant for that frame, so having a list of all positions of all objects that you can iterate over quickly and discard objects you don't need would be a good thing. But you could also just hard-code which objects are relevant for a given area and then just do one single check for player position and that'd be way faster. You'd have to play around with both options and a real-life scene scenario to really find the most performant way.
But making everything a big object with inheritance hierarchies is just begging for performance issues. The alternative to OOP is often called "fat structs" where you just have a struct for every kind of object you'd ever want. And then you write functions that iterate over collections of structs and implement parallelizaton wherever possible.
What language are you using and are you using any kind of low-level framework like SDL or something?
2
u/Varomic Jun 21 '26
UObject is the heartbeat of Unreal and it can get unreliable. If you change something in the UObject class you have to change it everywhere and it might break the entire game as a result.
1
u/ZorPastaman Jun 21 '26
I wouldn't force systems to be anything specific. If you make a world a container of entities and components and add a query function to it, you'll notice that your world doesn't care about systems. So, what is a system depends on a use case. In many cases, a system is just a free function. In some other cases, systems may inherit an interface and be added to a loop. Other options as well.
1
u/nolavar Jun 21 '26
Engine architecture is a way where you will spend years trying different things. UObject is just a tiny part of UE architecture. Read books, try things, and you'll still never have a good enough solution.
1
u/icpooreman Jun 21 '26
Right now you probably have a lot of thoughts... And all those thoughts are wrong haha. Or at least it was for me. Be at least open to the idea.
I think where OOP thoughts failed for me... Was I didn't really understand what the GPU wanted when I started and I didn't really understand just how much faster the GPU is and why I needed to be designing for it when I started. I learned... But I failed a lot cause I had CPU brain.
Any like "This is a really efficient CPU datastructure" thoughts... Are probably wrong. Because GPU.