Search Unity

ECS and Networking

Discussion in 'Entity Component System' started by floboc, Apr 12, 2018.

  1. floboc

    floboc

    Joined:
    Oct 31, 2017
    Posts:
    91
    Hello,

    I would like to have some insights on how networking is done when using an ECS ?
    I am familiar with client-side prediction, client/server-side reconciliation, interpolation, dead reckoning, etc. but I am not sure how would these be done in the ECS framework.

    For some reasons I have the intuition that an ECS should be well suited for networking since it is mostly data-based, but in practice I don't know where to start.

    For instance, client-side prediction and reconciliation implies to be able to override the current game state with an older state (reconcialitation with the state sent by the server) and re-apply some buffered input to simulate the game to the current time (prediction). How woud we achieve that ?

    I will be very grateful is anyone has some experience to share here :)
     
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I wrote some general idea of how I'd handle it here:
    https://forum.unity.com/threads/loo...vice-for-a-specific-case.526202/#post-3459645
    The problem is that I'm not sure if that sort of approach is actually possible in the current ECS, for reasons described in that post. Unless there's something I don't know, I feel like we aren't given enough control on the update loop

    The problem is a bit like trying to imagine how an equivalent of Physics.Simulate() would work in ECS. Imagine Unity eventually ships a "RigidbodySimulationSystem" as a package, to handle PureECS rigidbody simulation. When that system finds entities that have a RigidbodyComponent, it simulates it based on velocity, mass, etc.... But the problem arises when you want to simulate multiple times in the same frame (imagine you want to predict the trajectory of a rigidbody and display some visual indicator where it would land on the ground). How would that work?

    This post seems to suggest that you can't (or shouldn't?) call a system's Update from another system. So trying to simulate a trajectory by calling "RigidbodySimulationSystem.Update()" from somewhere else doesn't look like it would be an option

    It's also entirely possible that I'm just not thinking about this the right way, so if anyone wants to share their ideas on this that'd be great
     
    Last edited: Apr 13, 2018
  3. floboc

    floboc

    Joined:
    Oct 31, 2017
    Posts:
    91
    Thanks for your answer and the insights inside your post !
    You are right, I thought it ws already possible to manually update some systems but it seems that it is not the case.
    This seems like a must-have feature for networking