Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Advice needed on how to integrate ECS into project

Discussion in 'Entity Component System' started by Codecomp, Apr 15, 2020.

  1. Codecomp

    Codecomp

    Joined:
    Apr 17, 2019
    Posts:
    9
    I'm trying to build a basic space sim game so I'm going to end up with a lot of entities all doing their own pathfinding and deciding what to do next, and there will be a lot of potential bullets in play. I decided that I'd give ECS a try to see if I can simulate the entire game world without needing to limit what goes on outside the players field of influence.

    The issue is I'm finding ECS in it's current form to be a trial. I made a quick flyable demo a while back in monobehaviours and it took 4 hours. to get back to where I was it's taken me a good week. A lot of that is wrapping my head around ECS and getting back into unity. But a lot is also having to dig up the correct new syntax that;'s frequently changing.

    So I am leaning more towards using hybrid ECS. For things without much to them; Bullets going the ECS route is an obvious win. But the major issue is still the path finding and decision logic.

    So I'm considering using ECS to possibly puppet the ships in the game. Every time a new gameObject is instantiated, also create a entity for that ship referencing the game object. Having ECS tell the ship what it's goal is. But meshing the two together feels like it would be just as much hassle as going pure ECS.

    Does anyone have any advice for a good way to go about this? I've spent more time flip flopping on how to go about building this project than actually working on it at this point.
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    That's because hybrid is changing just as fast as pure ECS.

    My best advice is to go as pure as possible but also as small as possible. While the API might still be evolving, the core concepts and the way you reason about your code in ECS has remained the same. As you get familiar with it, each new API change will start to feel more like a new coat of paint rather than a new house.

    And by small, I mean really small, so that you finish before ECS has a chance to change. Last summer there was a period where I was doing a bunch of weekend game jams to practice and get a better understanding for the requirements for my personal framework. A few of them are available online:
    https://dreaming381.itch.io/

    The progression is as follows:
    Space Danger - Learning the ECS API to spawn entities using authoring components and driving things with input. Collision never worked.

    Sheep or Fall - Got collision working and a fun gameplay concept.

    Density Discrepencies - I spent significantly less time on this one, but got better scene management and mementos working in a very short amount of time.

    There's a few forum threads and video tutorials on A* pathfinding in DOTS. For decision logic, it is ok to have one large component with a bunch of state and one large system that operates with it, at least when prototyping. While many people will discuss the optimal ways to do things for performance, even naive approaches in DOTS are pretty fast compared to GameObjects. For most people, just using DOTS is going to provide them more than enough performance headroom to hit their target without much worry.
     
  3. Codecomp

    Codecomp

    Joined:
    Apr 17, 2019
    Posts:
    9
    Thanks for the reply.

    Are you referring to a component and system being as specific and drilled down as possible, or on a more general "just get the game out before it changes again".

    I haven't seen much from people talking about the late, but thought I'd ask as I've also not seen much about parts of ECS being depreciated, but i have seen some older methods that still work.
     
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    Sorry. But I am not sure what you are asking.
     
  5. Codecomp

    Codecomp

    Joined:
    Apr 17, 2019
    Posts:
    9
    You said to work as small as possible, are you meaning work on very small projects until ECS is more stable or chop up game functionality into as small a components as possible?
     
  6. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    Very small projects. You'll find that you will be able to borrow a lot more from these small projects in DOTS compared to GameObjects, but this also gives you the option to improve designs as you gain experience and adapt to DOTS evolution.
     
  7. axxessdenied

    axxessdenied

    Joined:
    Nov 29, 2016
    Posts:
    33
  8. Codecomp

    Codecomp

    Joined:
    Apr 17, 2019
    Posts:
    9
    @axxessdenied Thanks for the link, I had a look at her videos, even bought a couple of her Udemy courses as my friend can make use of them and I can trawl them for code snippets. I noticed shes very bad at saying why she's doing anything which is a shame. The other videos on technique seem better than the ECS stuff, though not deep dived yet.