Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Why you are using ECS in such a simple FPS project?

Discussion in 'FPS.Sample Game' started by Artaani, Oct 25, 2018.

  1. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    410
    What a point of using an ECS in a simple first person shooter?
    ECS is 1000 times harder to use than a current way of coding, the only advantages of ECS - CPU performance.

    But FPS is a very simple genre, there is nothing which may require a lot of CPU performance. So it have no any sense. If you want to show an advantages of ECS, would it be better to show it in some kind of mass scale RTS game?

    I saw a source code of this project, and everything is super overcomplicated.
    Is there a reason for that?


    Upd:
    To be clear, I am not a hater. On the contrary, I am love Unity, this is why I am worrying about its wrong decisions.
     
    Last edited: Oct 27, 2018
    Romenics likes this.
  2. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    490
    Hi, FPS is not a simple genre. I think you've only seen only simple FPS games. FPS is the game that needs to both CPU and GPU to the limit and performance is everything. On that note, I'm actually excited to see ECS in the code. If there were showing old technique, what's the point of another sample? If you want to see some examples, you may as well take a look at other FPS assets. There are plethora of them. I was also expecting some simple example showing how multiply games are done in ECS but I think it's both good and bad that they are trying create really nice examples. Since they took show-it-all path, I would like them to keep pushing and make commercial quality FPS game instead of just stopping here. Unity has been blamed not eating their own food and it might be a good chance to overthrow it.
     
    theDiver likes this.
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,436
    No need to read any further, folks.
     
    rizu, GuardHei, hippocoder and 9 others like this.
  4. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    100
    Last week I tried to implement ECS to one of my existing single player FPS game. I generated 1000 monsters (sounds crazy?) and wanted to see how powerful ECS is. End up all the physics stuck in one core (no multithread for physics?) and the game still lagged as hell. I believe I do not understand ECS well and I am glad to see if Unity can release more examples on how to make use of ECS and why.
     
  5. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    410
    So you think that PvP FPS with up to 16 players (like in this sample) it is a complex genre?

    What a complex things here? 16 simple character controllers and 10-200 projectiles? This is very simple tasks which does not requires high performance at all.

    I want to say that a demo from this video is much more suitable in order to show a benefits of ECS.


    This is exactly what I am talking.
    In my opinion, implementation of ECS in a PvP 8x8 FPS game - it is overkill. Such genre can be implemented long time ago using much more easier to use approaches.
     
    Last edited: Oct 26, 2018
    PixelLifetime likes this.
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,518
    It's definitely more difficult but it's nowhere near as difficult as you seem to be making it out. An experienced programmer shouldn't have any problems learning it and I'm inclined to believe that this sample project isn't aimed at anyone else but I haven't done more than skim through the repo.
     
  7. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    410
    You see what the problem is, Unity released a low-scale FPS shooter which created using ECS, so basically, Unity said: "Our new ECS is so good so it should be used everywhere, even in a simple FPS game".

    As result, many people will start to use ECS in cases where it is not required at all, and in result, even if developer is experienced programmer and even if he is learned how to use ECS, still, due complexity of ECS, development time will be longer in several times and overall, developer will not receive anything in exchange, because good optimizations and performance in FPS can be achieved without any ECS.

    Currently it is not a big problem since this sample was released just recently. However, if in the future Unity will advertise this sample everywhere in tutorials I am worrying, a lot of beginner (and not only beginner) developers will go a wrong way.

    And my worries are not groundless, this already happened with UNET. Unity advertised it everywhere and a lot of people struggled to learn it, but in most many cases, without success. Now UNET deprecated at all, as result, a lot of time and efforts of many developers among the world was wasted.

    I am afraid the same may happens with ECS if Unity will be not careful enough with it.
     
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,518
    Funny because I saw a completely different scenario. Learning UNET was only a problem for the brief period of time when there were zero resources and examples. Once they provided them though the problem shifted to one of a different nature which was that there were numerous shortcomings and Unity seemed to have abandoned it almost immediately.

    Except it's not wasted effort because while Unity may have deprecated it the community kept working on it. What previously could only barely handle co-op levels of gameplay can now handle hundreds of connections if needed.

    https://forum.unity.com/threads/mirror-networking-for-unity-aka-hlapi-community-edition.425437/
     
    Last edited: Oct 26, 2018
  9. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    410
    Many people will think:

    "Maybe I did not understood something? Hey, they are Unity Team, they are probably know what they are doing, so I should to learn UNET (ECS) harder. There should be a way to use it properly!"

    Unity have authority, people believe to what Unity will said, so this learning process may take a lot of time.
    For example here is what vis2k (developer of Mirror network) said:

    https://github.com/vis2k/Mirror/wiki/Why-TCP-by-default-and-not-UDP?
    "We spent about half our work hours from 2015 to 2018 dealing with UNET bugs"
     
  10. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,436
    I agree, once evaluated at scale UNET was found lacking. More samples, practical exercises and the public eye on new systems early are going to ensure that they are solid and relevant solutions in the long term. The UNET team was a group of - iirc - four developers which later moved to other sections as internally I'm sure they noticed that they were going to go in an entirely different direction in the next year or two as ECS become the cornerstone project for the foreseeable future.

    Your comment about FPS games being too simple for ECS is very shallow. Conceptually all genres can be broken down into simple terms but the genre is not what dictates the need for optimized architecture - the scope of the design does that. Being an RTS does not mean you have thousands of units, that is a design scope predication.

    There are a bunch of technical concerns with ECS other than "it's hard" and these sorts of demos are going to help sort out those issues, prove the value of the system and really help find integration gaps in the IDE as well as core API. Aside from that there is a high demand for high quality demos from Unity as there is a low-quality stigma attached to it in general which needs to be buried. To suggest that this was a stupid idea is to miss the big picture entirely.

    That being said, virtually everything is hard until you learn how to do it. ECS is different and new, but once standardized there will be no point in having this argument.
     
    Litwin, Evil-Otaku and Ryiah like this.
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,562
    FPS project mostly uses ECS in hybrid for what I believe (I haven't asked Unity) to be the following reasons:
    • All of Unity's systems will have ECS versions
    • ECS is faster even for a few things. It's just flat out more efficient
    • It helps unity discover the bad parts of ECS and make improvements
    • It's still only hybrid (mostly) so it'll at least teach people how to solve some ECS problems
    • Scalability. Next year when they click the make battle royale 100 player button it just works
    It is harder right now because it's still in the ugly duckling phase. So much so I think it'll only make sense for people really into it. Everything will be properly clarified and documented once Unity's figured what the final mutant form is.

    If you guys could document where you have problems it would be really helpful for @Joachim_Ante and team to look at...
     
  12. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    410
    Understood. I still can't understand what a problem with scalability was before ECS, in my opinion everything may have perfect scalability if designed properly, but will see how ECS will look in the future. Overall, yes, it have a sense.

    Thank you for detailed answer.
     
    Romenics likes this.
  13. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,518
    But if "designed properly" will it resemble the normal way of using Unity? And even if it does mostly resemble the normal way of using Unity, how much time will you have spent making it both "designed properly" while still retaining the normal way?

    I might be completely wrong here but I see ECS as a way of providing you with one approach that can be used for every game rather than having to design a new approach for every new game (or at least design far less). It might be more difficult to learn initially but in the long term I believe it will save you time simply by being that one way you've learned.

    By the way Unity's ECS is not the first time we've had an ECS framework for Unity. Entitas was one of the first publicly available ECS frameworks for Unity (at least to my knowledge). It's been around for a few years now.

    https://github.com/sschmid/Entitas-CSharp
     
    Last edited: Oct 27, 2018
  14. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,855
    Things like fine tuned memory layouts are super hard or impossible without ECS and these become rather important when you have to iterate over a lot of stuff -> scalability.
     
  15. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    410
    It seemed to me that situation is exactly opposite. ECS provides an ultra performance, but requires to develop a systems which are suitable only for specific game and features, and not suitable for anything else.

    But maybe I am wrong about ECS.
    Anyway, as hippocoder said, ECS still on early stage of development, so let's see how it will looks like in the future, and most important, a tutorials about ECS.
     
  16. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,194
    No, not at all. For example, the ECS package already contains an instanced renderer which is suitable for a great many games - provided you've attached the components that the system is looking for, then it'll just work. In this regard it's really no different to MonoBehaviours.

    It's true that the FPS Sample project, today, doesn't have any situations with huge numbers of entities - I think the last time I checked it had about 300 in total, which is a long way from the 4,500,000 we had in the MegaCity demo. However, as the team have said, this is project is not 'done' - the plan is to continue working on it, extending it and incorporating new engine features as they become available. It's easy to imagine that this could include adopting more ECS features as they become available - whether that is the rendering systems from MegaCity, or other things like new networking code (which has been a key use case in the ECS design process).

    It also means that if you want to 'mod' the demo with your own features which do have large numbers of objects, then you've already got the ECS framework right there in the project to slot your systems into. I've actually done exactly this myself as a hackweek/spare-time project to help me learn ECS - I added a load of alien birds that perch on the cables that are set up in the level and fly away if the player gets too close or shoots at them, and I added functioning doors in all the doorways (the art you need is actually in the project, it's just not wired up).
     
    Artaani and Ryiah like this.
  17. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,562
    Er, I hope the alien birds get added! That sounds rather brilliant and fun.
     
  18. xTy3

    xTy3

    Joined:
    Jun 14, 2018
    Posts:
    1
  19. Mogens_H

    Mogens_H

    Unity Technologies

    Joined:
    Mar 7, 2017
    Posts:
    20
    You are right. If we were a "real" game team that wanted to ship a 16 player FPS we would probably opt for a more traditional game structure and not depend on experimental features like ECS.

    But our goal is also to dogfood new features being developed so we want to stay pretty close to features as they come in. We do by no means think that what we have now is a perfect solution for how to structure ECS gamecode - we are also learning. But we hope that ECS and our gamecode code will mature beautifully together.:)

    And regarding the 16 players. We will make sure that number goes up
     
    Artaani and optimise like this.
  20. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    537
    If you have access to GDC Vault, take a look at Overwatch Gameplay Architecture and Netcode. I like this video, Blizzard explains how ECS and stuff work for their session-based shooter and how it help to the developers to solve many problems regarding netcode, node-based scripting for non-programmers, and many other things.

    The implementation of Overwatch-like ECS is available here (useful for learning purposes).
     
    Artaani likes this.
  21. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    282
    Besides, the fact that it is ECS means that a) it provides a great example into learning ECS code in practice and b) it's great for SpatialOS, which could easily handle 200-1000+ players.
     
  22. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    375
    Further
    This is not true. At first I had a headache figuring out how to structure my project, but ECS is in fact much more simpler than the traditional way of doing things.

    Here's an example:

    Code (CSharp):
    1.  public class WorldTimeAnimatorSystem : ComponentSystem
    2.     {
    3.         public struct Data
    4.         {
    5.             public readonly int Length;
    6.             public ComponentDataArray<WorldTimeReceiver> Receiver;
    7.             public ComponentArray<Animator> Animator;
    8.         }
    9.  
    10.         [Inject] Data _data;
    11.  
    12.         protected override void OnUpdate()
    13.         {
    14.             for (int i = 0; i < _data.Length; i++)
    15.             {
    16.                 _data.Animator[i].SetFloat("NormalizedTime", WorldTimeSystem.NormalizedWorldTime);
    17.             }
    18.         }
    19.     }
    This will update all Animators with an attached WorldTimeReceiver so it follows the in-game time of day. I can have any animator in any context affected by the system as long as it meets its criteras, which is extremely powerful.

    Furthermore, if I'm tired of my day & night cycle, I can just remove the system and everything else will just work.

    I was first afraid of ECS complexity, but I think it may just be the way it is explained that is confusing. Especially if you are trying to master ECS + Jobs + Burst all at the same time.
     
    Guerro323 likes this.