Search Unity

Can we speak about Hybrid ECS here ?

Discussion in 'Data Oriented Technology Stack' started by Cassiopee, Dec 16, 2018.

  1. Cassiopee

    Cassiopee

    Joined:
    Oct 25, 2016
    Posts:
    15
    Hello all,
    I saw few things about ECS and Jobs System but when it comes to Hybrid ECS i struggle a lot finding informations/examples. can i ask questions about Hybrid ECS here ? Thanks.
     
    hippocoder likes this.
  2. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    420
    Yes, go ahead.
     
    hippocoder likes this.
  3. GliderGuy

    GliderGuy

    Joined:
    Dec 14, 2018
    Posts:
    28
    Well, of course you can ask questions about ECS here! It is indeed the Entity Component System and C# Job System forum section. The real question is what questions do you have -- and would you mind sharing? Under normal circumstances I would recommend making a new thread for the question, but since this one is practically fresh i believe it would be alright to ask what questions you might have right here... Provided you don't feel like they're thread-worthy. Another option is to use the forums Answers** section, which in my opinion is great for smaller questions in which the forums layout or features may not be necessary for.
    **It should be located near the top-left of your screen, right next to the blue "Forums" section. Provided you are on a PC.

    All in all, it's your decision. But do please take my thoughts with a grain of salt! I'm new here as well, and i more than likely don't have all my facts straight just yet!
     
  4. Cassiopee

    Cassiopee

    Joined:
    Oct 25, 2016
    Posts:
    15
    Thanks for your answers ! I asked because i was not sure that thus is the right place
    First, ECS and Jobs Systems are beyond my understanding. Hybrid on the other hand allow me to learn another way of thinking while relying on what i already know of components.

    I recently had a look at networking and i wonder wf hybrid ECS can use the Network Transform Component

    On the Host/server it work well and client see host moving properly
    On the client, it do try to move but keep have its position reseted (by i dont know what) and no movement appear on the server. Any idea ?

    I'm new in unity's forum. I often ask things on reddit but i didnt had reply for that one. I'll have a look at the Question Section. Thanks !
     
  5. iam2bam

    iam2bam

    Joined:
    Mar 9, 2016
    Posts:
    36
    Hi, it was hard for me as well to understand how to communicate between "styles" (ecs and classic). I think everybody could benefit from more samples and better documentation.

    Some pointers (anyone correct me if I'm wrong):
    For hybrid systems, synchronization between ECS and Classic should happen on the main thread, i.e. not inside jobs.
    You can still use ComponentSystem with dependency injection [Inject], [UpdateBefore/After] to set system run order, and iterate inside OnUpdate over injected ComponentDataArray (ComponentData from entities) and ComponentArray (classic-style Components) to mix things up.
    Also your classic GameObject/prefab having a GameObjectEntity Component (added from the Editor) will automatically create an entity when you Instantiate the old way. To access it: gameObject.GetComponent<GameObjectEntity>().Entity
     
    GliderGuy likes this.
  6. Cassiopee

    Cassiopee

    Joined:
    Oct 25, 2016
    Posts:
    15
    what you are talking about means very little to me. i'm lacking lot of knowledge about how things are sync in ECS, i'm afraid ^^
    Though, i didnt ran into sync problem yet (in single player prototype). and at the moment my problem seems more like two systems (from host and from clients) acting against each other. It Might be a sync problem too but anyway they should not interact from the beggining anyway.

    this is the way i use to discriminate Entities inside a system.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using Unity.Entities;
    4. using Hybrid.Components;
    5. using UnityEngine.Networking;
    6.  
    7. public class PlayerMovementSystem : ComponentSystem {
    8.  
    9.     private struct Group
    10.     {
    11.         public NetworkIdentity networkIdentity;
    12.  
    13.         public Transform transform;
    14.         public PlayerInput playerInput;
    15.         public Speed speed;
    16.     }
    17.  
    18.     protected override void OnUpdate()
    19.     {
    20.         //every player.entity are indeed registered in the Group...
    21.         foreach (var entity in GetEntities<Group>())
    22.         {
    23.             //...but only the LocalPlayer should move
    24.             if (entity.networkIdentity.isLocalPlayer)
    25.             {
    26.                 Move(entity);
    27.             }
    28.         }
    29.     }
    30. }
    Unfortunatly, it work only on the Host-(Local)Player to Client-(host)Player.

    the Host - Player 1 move
    the Client- Player 1 do move too

    but if the Client - Player 2 move, it giggles and go back promptly into initial position.
    the Host - Player 2 dont move at all.
    its like something is reseting Player 2's position from the Host side and pushes it to the Client side.
     
  7. iam2bam

    iam2bam

    Joined:
    Mar 9, 2016
    Posts:
    36
    By sync I just meant copying values between a classic component (MonoBehaviour, RigidBody etc) an a ECS one (implementing IComponentData). I thought you were having issues communicating between jobified and not, I'm afraid I never used Unity's networking so can't help you there. Good luck!
     
    GliderGuy likes this.
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,349
    Post 1 thread her per problem. It is OK and more useful to post 1 clear thread per problem and put part of the problem in topic title. Staff and enthusiasts do love ECS based problems to solve (me included), and it's easier to find older problems people had when ECS is being developed if it's 1 per thread :)

    Don't worry about being spammy, that is beneficial here, more threads = better ;)
     
    Mr-Mechanical likes this.
  9. Cassiopee

    Cassiopee

    Joined:
    Oct 25, 2016
    Posts:
    15
    yes you are right. i'll close thise one and make a new thread with clearer informations about my problem. thanks :)
     
  10. Cassiopee

    Cassiopee

    Joined:
    Oct 25, 2016
    Posts:
    15
    Hum. Today, wanting to record a video, i tried again. The behaviour of my players changed and i was now able to move my player on the client side.
    i am a noob at network so i forgot to check "Local Player Authority" on the Network Identity component. Checking it solving my second problem (that my Client didnt move properly on the Server's side).
    That do not explain what was initial problem but eyh, it works now ^^