Replies: 2 comments 1 reply
-
How to synchronize a registry over a network really depends on what you're trying to achieve. There doesn't exist a one-catch-all solution and this doesn't depend on the specific library in use. To answer your questions instead, of course you can tag entities with a dedicated component. Probably you don't want to take all the components that have been changed though. More often than not there are data that should not be sent to a server because they are useful only for the local simulation. Among other things, while writing I realized that the best approach for your case also depends on how you want to send the data over the network. Divided by entity, by component type, and so on. Again, the problem defines the solution. I'm looking forward to your feedback to continue the discussion. 👍 |
Beta Was this translation helpful? Give feedback.
-
I know this is an old post but I have been thinking about this problem for my game. Yes have something like a NetSync component and when the client creates an entity it will send a message to the server saying an entity is created. The server will create an entity in its own registry and put the client entity ID into the component. It will then send its entity ID back to the client which will put it into the clients NetSync component. The server will send a message to all other clients saying that a new entity has been created and the other clients will create a new entity with the server's entity ID in the NetSync component. I think the better approach would be to update the server when an event has occurred like creating a new entity or if the user and pressed the forward button etc |
Beta Was this translation helpful? Give feedback.
-
Hello everyone!
Surely this issue has been discussed more than once and I think this problem has been solved already, but I have not yet been able to find such a solution for myself.
The entt library is gorgeous and I have successfully used a lot including ECS itself in new project. But I am facing the problem of using entt with networking. It is supposed to use an authoritative server and dummy clients to create a multiplayer game. The basic idea is to keep the server registry synchronized with the client's one. This synchronization should happen every iteration of the game loop (like every 33 ms). Ideally, when forming a packet with the next updated world, you need to send only what has changed directly and at the same time be able to send the full state if a connection failure occurs.
I know that entt has a lot of building blocks for this, like continuous loader, change observers, dependencies. But I can't manage to combine all this into a convenient API for working with synchronization. It is possible to mark an entity with the
NetSync
like component, take these entities in the appropriate system, and what next? How do I get only those components that have been changed? It is possible to make a callback function in the componentNetSync
, which will provide a call list of components required for synchronization, but how to understand if a specific component has been changed at this moment?Moreover, there is a wonderful thing as a continuous loader. How will the synchronization of the removal of components or the removal of entities take place?
Beta Was this translation helpful? Give feedback.
All reactions