3 ms·
One day I'll write a blog post myself writing about how I went from ECS to OOP. The short version is that ECS works against creativity. I want my entities to b
by Jyaif 8y ago
One day I'll write a blog post myself writing about how I went from ECS to OOP.
The short version is that ECS works against creativity. I want my entities to be unique: they move differently, they react to damage differently, they die differently, etc...
In a ECS world, this means having at least 5 different components and 5 different systems per... type of entities.
With just 10 entities you already have 100 different classes... that are never going to be reused.
Also, because I reimplemented my game to OOP I was also able to compare the performance and noticed that the ECS performed worse (although maybe my implementation was not good?).
- skypjack 8y agoMaybe. However it makes sense to stick with the paradigm with which you are more comfortable. There is no shame with using OOP instead of component-based models or the other way around. I think that knowing both of them can help sometimes, because they fit different problems and can work side-by-side tho. That said, if you'll ever write such an article, ping me!! I'm pretty sure it will be an interesting point of view to think of.
- dkersten 8y ago> In a ECS world, this means having at least 5 different components and 5 different systems per... type of entities. Shouldn't it be more data data-driven than that? That is, instead of 5 components and 5 systems, you have one or two components and one or two systems and the components declarative describe the differing behaviours in a data-driven manner. In my personal experience, if you have objects or inheritance to define every possible behaviour, the codebase becomes a huge tangle and performance will suck and actually creating the content becomes a pain. I'd personally much rather have components that define the general flavour of the behaviour and then use data to fine-tune it. And for the edgy edge cases.. have a script component that runs Lua or whatever. Of course, you can do that with OOP too and you can certainly write high performance OOP, I just personally find it much harder due to how it encourages distributing state across the codebase, especially when you want to do it in a multithreaded environment. But if you've had better experiences with OOP, then more power to you, use what works for you. I would, however, not write my own ECS, but use a well designed and well tuned existing one, like the article authors EnTT.