Search Unity

Noob question about ECS and the Job System

Discussion in 'Entity Component System' started by JediNizar, Jan 23, 2019.

  1. JediNizar

    JediNizar

    Joined:
    Nov 13, 2016
    Posts:
    111
    Hi,
    First of all I'm still a learner and working with unity on my spare time,
    So sorry for this question :).

    All the demos, and tutorials I have seen regarding ECS and the Job System, are showing the benefit of its use, when it comes to having a lot of gameobjects (which are doing something/ have attached some scripts) at once or spawning a lot of object etc...

    But what if my current project don't have to deal with many of these kind of objects.
    all I have in my project is one Character moving inside a house and solving some puzzles, here and there a new object spawn but max let we say max. 10 at once. is there any use of the new system, for such a project?

    for just many static objects like (3d models) what I'm currently doing is Combine Meshes and use texture altas etc..

    Or should or can I use the job system for rendering these objects too?

    did I miss understood something?
     
    Last edited: Jan 23, 2019
  2. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Yes of course. Don't think of "I only have 1 Character and some other stuff"

    You need to think component wise: Each object has a position, rotation, scale. Each need to be rendered.
    So, this stuff can be jobified and share some components.

    The next thing is:
    With ECS you have a better scalability of features. E.g. at some point in your dev time you want to add a new feature.. In most cases it's just adding a component and a system for that feature.

    The codebase is just easierer to maintain than oop.

    The down side is, that it has some learning curve. Especailly when you're coming from oop..

    Anyway you can just profit from it!
     
  3. JediNizar

    JediNizar

    Joined:
    Nov 13, 2016
    Posts:
    111
    thanks a lot for that answer.
    I think I still don't know the use of this new system. As I understood it, it's like executing everything in a new thread.
     
  4. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Thats exactly what jobs does. They are exectuted in a different thread in parallel!
    The ECS was introduced only as a means to an end.
     
  5. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    This is going to be an unpopular opinion in here but honestly for a small puzzle game with a limited and mostly static environment the ecs and job system offer you little of value.

    Stick with then gameobject and monobehaviour system for a game like that.
     
    dadude123 likes this.
  6. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    I can agree with this up to a point...

    Pros of ECS
    • It will allow you to build up a set of atomic systems that you can re-use across projects.*
    • It will take advantage of more cores and run faster or with less impact on battery/power usage.

    Cons of ECS
    • *ECS is still a work in progress so therefore a moving and changing platform.
    • The boilerplate nature of ECS means you will be writing lots of code just to run a single line function, so it can be slower to build up the systems.
    • It is not visible/tactile within the IDE the way Monobehaviour GameObjects are e.g. you don't know what your scene will look like until you run it.
    • A lot of default API systems in Unity have not transferred to ECS yet so you will need a hybrid approach to add things like physics, animation, sound and particle effects.
    Possibly the best approach at the moment would be to build your game using Monobehaviour and benchmark it to see if there are any systems that are underperforming and could benefit from the optimisation ECS brings.

    You could also play with ECS to provide atmosphere or character to your game world e.g. weather/wildlife things that would otherwise tend to be static but would be given life with the power of ECS.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    Just to add, depending how much of ECS you make in game, probably you could gain some battery life time on mobiles devices.
     
  8. JediNizar

    JediNizar

    Joined:
    Nov 13, 2016
    Posts:
    111
    My target platform is mobile VR / Ocolus go hopefully also Ocolus quest.

    So taking care for performance is a must. I wander if the new jobsystem can help with the lights using/adding real lights or dynamic shadows.
     
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    I think these will be dealt on gpu rather cpu. But don't quote me on that.
     
  10. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    In VR FPS is King, and Occulus Go is a mobile CPU/GPU you will be very limited in processing power and graphics capabilities.

    However ECS might give you enough of a performance boost to do more interesting things, maybe not as graphically intense as additional lights and shadows. e.g. you could add glowing orbs (shaders with emit and a halo effect).

    The thing is build it and benchmark/profile it often on the hardware.
     
  11. JediNizar

    JediNizar

    Joined:
    Nov 13, 2016
    Posts:
    111
    Thank for the tips.
    Currently I'm testing my project on a Samsung Galaxy S7, and it's quite stable.
    Still, there are tons to do so I'm not sure how the performance will evaluate, especially that the main aspect of the game is not implemented yet.
    The only place where I counter lags is in a hall with ropes hanging from the ceiling and there is a mirror reflecting the player only. I'm using the obi system for the ropes.
    So that's why I thought maybe I should switch to the new job system to try to enhance the performance, I thought, especially I could use it for rendering the decals.
    Also, I have an outside scene a forest which I only use for a "cut scene". and I thought maybe I can make it a little bit dense right now to make it work the trees are grouped together in a single mesh to decrease draw calls. but as you said in your previous answer, all is static there is no life in that forest
     
    Last edited: Jan 25, 2019