Search Unity

Resolved Is ECS the same as component-based programming?

Discussion in 'Entity Component System' started by MessiasOF, Oct 22, 2020.

  1. MessiasOF

    MessiasOF

    Joined:
    May 4, 2017
    Posts:
    27
    Hi,
    I was watching a video about what ECS is in a very briefly way (this one), and now I am confused. My initial plan for my game was modular component-based programming, just like in this post:

    [unity forum thread link]
    my main goal is to make my game have a modular programming (which is good for debugging and making it easier for modders and for me).

    But apparently Unity ECS (from what I understand) already does that and a little more.
    Based on the post link mentioned earlier, is the ECS the same thing as programming using components? What would be the difference between using ECS and component-based programming?
     
  2. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    ECS is entity-component-system. Entities are just an index that "connects" multiple Components together, Components are just data that Systems uses as input/output, Systems are where the logic is implemented. Here everything is about data (data-oriented design)

    Component-based programming is a very broad term but the thread you linked too is about OOP composition which is the way that the standard Unity works. MonoBehaviour have both the data and the logic. Here everything is object-oriented.
     
    MessiasOF likes this.
  3. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Oh my... a little more.
    I am so sure that you will be absolutely overwhelmed. As everyone else does.;)
     
  4. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    The free webbook Data-Oriented Design by Richard Fabian gives a good introduction into DOD. It's not specifically for Unity but covers more the philosophy behind DOD. If you decide to use ECS (which I encourage albeit it's a bit rough yet) it is a "must read". The printed version contains more content.
     
  5. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Both ECS and Unity's current tech stack (MonoBehaviours) are component-based.

    If you just want to get 'er done, use Unity's current-gen tech and wait on ECS. MonoBehaviour is MUCH more modder-friendly (likely even after ECS is released, since some of the choices in ECS don't lend themselves well to modding the same way that object-oriented code does). Which one is easier to debug is debatable; someday ECS probably will be, but right now there aren't many debugging tools, so you'll likely have an easier time in MB land.

    If you're looking to learn something on a hobby project, ECS is a good choice. Also, if you need very high performance on a CPU-bound game, full ECS can be the way to go -- if you're doing a large open world, an RTS with thousands of units per side, or a massive city sim, ECS starts getting very tempting.

    However, you can use jobs+burst from MonoBehaviour which will get you a lot of the advantages of DOTS without having to restructure your game or use SRPs.
     
    Last edited: Oct 24, 2020
    MessiasOF likes this.
  6. MessiasOF

    MessiasOF

    Joined:
    May 4, 2017
    Posts:
    27
    Wow, I didn't expect to receive so many well-explained responses in such a short period of time.
    Really thanks for the answers, they ended up solving my doubts and others that could come in the future.
     
    PublicEnumE and brunocoimbra like this.