In my prototype, which is this one btw
when a local unit picks an action (move, shoot, etc), I call a Command which in turn calls an ClientRpc method on all clients, for example:
override public void HandleConfirmClick()
{
CmdHunker();
}
[Command]
void CmdHunker()
{
RpcHunker();
}
[ClientRpc]
void RpcHunker()
{
_gridAgent.Hunkering = true;
InvokeActionConfirmed(this);
Deactivate();
InvokeActionComplete(this);
}
Nothing out of the ordinary. Cmd and Rpc prefixes are for clarity.
Since the game is turn-based, after the action is decided, each client proceeds with its execution independently, and they will all do the same thing, except when there is randomness involved (hit/miss, random damage, crits, etc.).
The need for a random value may occur down the line at the end of a series of events involving several objects interacting, projectiles, explosions, timers etc, so I don’t think in such a scenario one would synchronize/centralize everything, it sounds like a nightmare.
I found several posts, here and elsewhere, on similar issues, some suggesting to use a custom random generator initialized on all clients with the same seed. I followed this approach before in other platforms (XNA), but I don’t really like this solution, and it also appears to have issues with random generator implementations depending on CPU architecture etc, so I am looking for alternatives.
Any suggestions?