Question for Netcode for Gameobjects

Hello,

I am still new to learning netcode, so I apologize if my question is answered in the documentation but I could not find an answer.

I am wondering if it is possible to have a network object update not on every frame, but when we tell is too.
For example I want to have a building create 1 wood resource after 1 minute, I only need to send the code to the network every 1 min to say the wood was created, I don't need to update this every frame, it would allow me to have thousands of buildings vs having a few since they would rarely update.

Is this possible?

Thank you

You are correct in thinking that you should only be sending the information that you need at the time that you need it when it comes to networked gameplay.

Ideally, you’ll have as little host/server logic running as you can get away with.

So taking your example into consideration, you’ll want the Server/host to be in control of the time and your buildings to be receiving those time changes (as ServerRPCs) and checking for when a minute is up and then generating their resources. If time is all that you care about, then make that server-side and everything else local. This will ensure that all clients are getting the same time at the same interval, but you don’t need to send the whole object or have the server know about it directly at all times (e.g. every update).

Now you could approach this in different ways, having the clients send RPCs out to the server every minute and update the server’s building, but then you’ll have more server CPU consumption in order to maintain that simulation and that could get expensive. It really depends on what experience you want to build.

Adding to the last paragraph, if the client sends these „got wood“ updates itself this is less secure in terms of cheating. Players could hack the client executable so it produces wood at a faster rate and the server would just accept that without additional logic (which would be tricky to write).

1 Like