Hey everyone, I am building a multiplayer RTS style game which needs to keep hundreds of characters up to date over the network. I use RPC calls for everything so I can be very selective about what needs to be updated. Things are working pretty well so far, but I have a few questions about optimizing RPC calls.
I know Unity is very smart, and I was wondering if it does anything behind the scenes to compress int values? For example, I have a bunch of values which I know will never exceed 10. So I do something like...
void ReplicateAllValues( int valueA, int valueB, int valueC )
{
int valueSentWithRPC = valueA + valueB*10 + valueC*100 ;
networkView.RPC("ReceiveAllValues", RPCMode.All, valueSentWithRPC );
}
[RPC]
void ReceiveAllValues( int valueFromRPC )
{
int valueA = valueSentWithRPC % 10 ;
int valueB = (valueSentWithRPC % 100) /10 ;
int valueC = (valueSentWithRPC % 1000) /100;
}
Is this worth my time? Or does Unity do compression behind the scenes that makes this silly?
Secondly, how much bandwidth overhead is there for each RPC call? If I make 100 calls to a function which takes a single int, how much worse is that than calling a single function which takes 100 parameters?
Finally, am I correct in thinking that if I do not declare a NetworkMessageInfo parameter in my [RPC] function that bandwidth will be saved? Or is that information always sent reguardless?
Thanks