Hi, I am having trouble understanding UNET. I am developing a card game. Basically what I’m trying to do is to have the server to assign each player’s hand when all of them are connected. So I use SyncList to hold the card datas. When all of the hands are assigned for all players I want to call a function on each client to get the physical cards (gameObject) into their hand (the transforms are not synchronized, I dont want all players seeing the same scene, just the card datas on each hand should be same).
The problem is it seems like the callback on synclist only works on the server, I am not getting a printf on the client. When I tried to call ClientRPC function inside that callback, I get the error: “Trying to call RPC on client”. I am quite new with Unity’s Multiplayer and this is confusing to me.
//NetworkGameManager class
public override void OnStartServer()
{
for (int p = 0; p < gamePlayersList.count; p++)
{
for (int c = 0; c < 13; c++)
{
Card card = deck.GetNextCard();
gamePlayersList[p].cardDatas.Add(card.cardData);
}
}
}
//NetworkGamePlayer class with local authority
public SyncListCardData cardDatas = new SyncListCardData();
public override void OnStartClient()
{
cardDatas.Callback = OnCardDatasUpdated;
}
private void OnCardDatasUpdated(SyncList<CardData>.Operation op, int itemIndex)
{
if(itemIndex == 12)
{
GetCardsFromDeck();
//RpcGetCardsFromDeck();
}
}
private void GetCardsFromDeck()
{
Debug.Log("GetCardsFromDeck"); //debug only shown on server
}
[ClientRPC]
private void RpcGetCardsFromDeck()
{
Debug.Log("RpcGetCardsFromDeck"); //error: Trying to call RPC on client
}