I’m making an online 2-player Trading Card game.
At the start of the actual cardgame scene, the GameController sends an Rpc to both clients, asking them to send it their playerName and decklists, which are both saved locally as a simple string.
My Question is basically, when
myGui.SetPlayerData(resourceContainer.GetPlayerData());
is in the code, right below
clientController.RpcClientSendPlayerData();
will the function GetPlayerData() already return the data that is sent by the clients when RpcClientSendPlayerData is called?
Are Syncvards synched immidiately? Or will program wait until everything is synched before calling RpcClientSendPlayerData ?
Code Extracts:
(GameController, Server-only)
clientController.RpcClientSendPlayerData();
myGui.SetPlayerData(ResourceContainer.GetPlayerData());
(ClientController)
[ClientRpc]
public void RpcClientSendPlayerData()
{
localPlayer.CmdPlayerSendPlayerData();
}
(Script on the local player, local player authority)
[Command]
public void CmdPlayerSendPlayerData()
{
resourceContainer.SetPlayerData("host", myName, myDeckString);
}
(ResourceContainer)
[SyncVar]
string hostName;
[SyncVar]
string hostDeckString;
public void SetPlayerData(string player, string playerName, string deckString)
{
if (player == "host")
{
hostName = playerName;
hostDeckString = deckString;
}
}
Thanks in advance!