#Netcode best practices

1 messages · Page 1 of 1 (latest)

dark cove
#

I'm thinking about how should I approach some issues in my project.

Let's say we are building an RTS with netcode for entities.

Feature wise :

2 players are buildings stuff on a moving plateform ( not necessarely the same )
Some buildings extracts ressources , some transform them ( let's ignore the transport for example sake )

How should the code be organized in that context ?

My first thought would be :

Inputs from the players ( building something at that position , destroying something etc ... ) , should be send as rpc command from client to the server that then apply the command on his side.

If we have a factory producing stuff, that calculation should be made on the server & then send as snapshot to the clients so they can have that sync on their side.
Cheating is not a concern.
I'm trying to keep things as simple as possible.
Now I'm not sure how to say to netcode a few things :

Problem A :
On this building entity that is spawned from a prefab.

Sync the data of the production from the server -> updated by systems that execute only on the server.
Do not sync anything physics related ( cause not needed in my context )
Do not need to sync positions ( Maybe ? or should I just do the update of the localtransform on the server then let it replicate ? )
Do not need to sync visuals ( cause that should be only on the client , right ? )

Should I just not bother and sync everything on the entity ?

How to setup the entity properly so only relevant data are synced. ( I'm aware of the ghost authoring component but that sync everything and i'm thinking that's it's overkill for my usecase )

#

Problem B :
Both players are building a buildings & there are previews that need to be synced.

Same things, the building is first spawned from a prefab.

Should I setup the previews on the server and let netcode sync everything ?

#

Problem C :

Follow up on B: But this time the mesh is constantly changing in preview mode. ( think a pipe based on a spline )

What should be my approach on that if I want the previews to be synced on both side and the physics collision to be handled ?

The physics I guess could be handled on the server side but I feel like it's not necessary. It could be client side I think.

In that situation I would just sync the spline data on the network and let the client recalculated the meshes, right ?

But back to problem A Let's say some meshes are very big, how would that impact the snapshot size to sync them over the network if I go with the authoring road ?