Sync large amount of variables via Network

Hello Unity Answers,

I currently have a script that has a large amount of Static variables. It basically is a repository of data that controls almost everything. I am wondering if there is a simple and fast way to sync this scipt with 8 computers. There is 100ish variables, and most are strings.

Thanks, Kelhedros.

Why do you need that? On 60fps, with say 250 chars per string it's ~11.5MB each second. (Download and upload)

What are you trying to do?

You should look at your game and make sure these variables need to be synced (for example, if they are used to make an AI move around or something, are you sure you couldn't just do all the calculations with those variables on the server, and just sync the results to the clients?

Also, if you absolutely have to sync them, is it necessary that you sync them every frame, or could you get away with only syncing them once every second, once every half second, or even once every tenth of a second? For instance, I sync the health of my authoritative AI enemies from the server to the clients with an invokerepeating rpc every 0.25 seconds, and its about 8x less bytes/second than every frame, and the difference in gameplay is negligible.

My thoughts: I'd have a class where I call a SetValue method, which maintains the list of variables and their values. It would track each variable, and flag when its value has changed.

Then, I would have a Sync() method that sends only the values which have changed to the clients. This might or might not be what you are looking for though. If you want more info, I'd be glad to give more details.

On a side personally annoys me when someone asks how to do something, and gets "Why are you trying to do this?" Guys, at least assume it's for a good reason and give an idea of how to accomplish his original question, instead of asking the OP to justify his question and just leaving it at that.