#Architecture Question on Netcode for Entities

1 messages · Page 1 of 1 (latest)

gaunt urchin
#

Hey there ! Back at it and trying to wrap my head around some ideas there.
Prototyping a few stuff to see what netcode can do & how to do it?

Here is a few questions, I am reading a lot on the topic & please if you have good resources on each topic please let me know and i'll be sure the check & update each topic accordingly with what I learn.

So here are a few use cases I'm thinking about. and looking for the best ( or a decent ) architecture to solve the issue in a scalable way.

First :
Will we have proper Tutorials or Official Courses on the topic ? ( netcode for entities) when it's ready ?

Second :
Imagine a scenario where you have a survival game : if I understand well enought, players, resources ( trees , rocks etc ...) & anything that can move or be interacted with should be a ghost.
When interacting with these object, would we have to send RPC event to the server ? ( like player 4 hit the tree entity collider number xxx ) the server receive the event & then process the data , update the ghost , then... send the update to all players ?

Second Bis :
How should a tick system be managed with netcode with entities.

Third :
In a scenario of a city builder or factory builder where we would have a 'Tick' based simulation what would be the correct approach to sync the construction of the respective bases ? send RPC events to the server like : 'Player 2 want to Build Mine at that position' , 'Player 3 Want to Destroy the road entity' & then let the server manage the simulation update then send the new snapshots to the player with the new entity states ?

Fourth :
Same scenario than before but in the case of factory being on grounds that move around ( Dyson Sphere Program or Planetary Anihilation) are all the building entities going to be sent to all player each Tick ? or is it enought to just have a ghost of the time spent on the server & then let the clients calculate all the positions for all buildings depending on the orbits & starting positions ?

magic talon
#

Hey!

Will we have proper Tutorials or Official Courses on the topic ? ( netcode for entities) when it's ready ?
I strongly recommend looking at the published NetcodeSamples (especially the HelloNetcode samples, which form a kind of tutorial) inside EntitiesSamples (below), and reading the entire netcode doc Manual (below). Together, they should give you a strong overview about what is possible, and were to find specific information.

https://docs.unity3d.com/Packages/com.unity.netcode@1.0/manual/index.html

https://github.com/Unity-Technologies/EntityComponentSystemSamples

We're always working to improve docs and samples, but we have no guided tutorials or courses.

if I understand well enought, players, resources ( trees , rocks etc ...) & anything that can move or be interacted with should be a ghost.
Correct. If data needs to be replicated, it must be on a ghost.

When interacting with these object, would we have to send RPC event to the server ? ( like player 4 hit the tree entity collider number xxx ) the server receive the event & then process the data , update the ghost , then... send the update to all players ?
Mostly yes. Our netcode supports "client prediction", allowing gameplay systems to run non-authoritatively on the client as well as (authoritatively) on the server.

We also refer to those client RPCs as "commands", colloquially called "inputs".

I'd recommend reading the manual to learn more about:

  • IInputComponentData (a.k.a. Commands)
  • Prediction & the "Prediction Loop".
  • The distinction between Predicted and Interpolated entities.
  • Replication via Ghosts (via serialization).

How should a tick system be managed with netcode with entities.
Could you elaborate on this question, please?

what would be the correct approach to sync the construction of the respective bases
You most likely want this logic to be predicted (so it feels snappy and responsive). Thus, you'd use Commands.

#

I'd recommend your input struct be an Entity reference + some kind of instruction enum. That way, the server can process any actions you wish to take for each frame.

Same scenario than before but in the case of factory being on grounds that move around ( Dyson Sphere Program or Planetary Anihilation) are all the building entities going to be sent to all player each Tick ? or is it enought to just have a ghost of the time spent on the server & then let the clients calculate all the positions for all buildings depending on the orbits & starting positions ?
The latter. You really dont want to be sending data every frame for calculations that you can infer on the client. If the planet is a ghost, you can sync the rotation via:

  • A startTick.
  • A known / fixed start angle.
  • A known / fixed rotation speed.

Thus, buildings can have a fixed position when spawned, and that position can map to the spherical, rotated location.

#

Bandwidth optimization is pretty intuitive. I.e. If you send less data, you'll have lower CPU and $$ costs.

#

In other words; infer as much as you can on the client, using shared tick data. Author ghosts as Static.

gaunt urchin
#

"How should a tick system be managed with netcode with entities."

Sorry for the lack of precision : I'm taking factorio as example.
The simulation run with "server tick" where all the calculations on the factory is made then sent to clients.

How would you put that in action with netcode & how is that supposed to interact with Systems ( like a system running after a "server" tick ?

( this was the question )

#

Thanks for all the pointers ! I'm going to experiment on that and come back with either ore question or infos to share 🙂