After watching many sample code I was still confused about the ECS pattern, in the end I decided to just read some old articles about how to make an ECS in Unity (when it, of course, was not possible) and now I think I finally understand it… still I’m not really sure. Well I’ll just try to say what I think I have understand, just tell me if I’m right or wrong.
The main problem was, at least for me, that when unity try to explain what is a component it always say “it only contains data”… but, for what I’ve understand, Component contains variables (also other Entities variables)… and I know, maybe it’s the same thing, but my idea of data was “things that you read from a DB” (like in the MVC pattern were the model is the parts that communicates with the database).
So, if for monobehaviour it was an Entity-Component thing (where a GameObject was an Entity, and a Component was a script with variables and logic that you should apply to that GO), with ECS you have an Entity (GameObject) a Component (script without Start and Update, just variables), and finally we have the System a single script that loop the Entities and apply OnStart OnUpdate, Collision, Trigger etc… logic.
Example:
I have a CameraEntity
I have a Component that contains
public PlayerEntity target
the System can
get the CameraEntity and move the target.
Is that right, or I’m missing something?
If that is right
what’s different from doing a monobehaviour with reference to every GameObject on the scene? (every GO with their scripts that only holds variables with getters/setters)?
It is just a performance thing or there is something else that I’m missing?