Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Spawning a scriptable object with Networkserver.Spawn gives the generic scriptable object in client

Discussion in 'Multiplayer' started by Launceleyn, Dec 17, 2021.

  1. Launceleyn


    Dec 10, 2021
    I instantiate a new generic scriptable object, give it its values, the spawn it. This works on the host, but the client seems to just get a blank generic CardMain displayed. Like, I can see both players hands as the host, and no cards as the client. They can still interact with it in ways you can interact with a regular card, but try as I might I cannot figure out how to make the card show up for both players.

    Code (CSharp):
    3.    [Command]
    4.     public void CmdDealCards()
    5.     {
    8.             //Instantiating a blank scriptable card
    9.             GameObject card = Instantiate(CardMain, new Vector2(0, 0), Quaternion.identity);
    10.             //pulls a random set of stats for that card from a list
    11.             newcard = DrawCard();
    12.             //gives the blank card those stats
    13.             card.GetComponent<CardDisplay>().UpdateCard(newcard);
    14.             //Spawn the card  
    15.             NetworkServer.Spawn(card, connectionToClient);
    16.             //sets the card's parent to the player's hand whomst drew it
    17.             RpcShowCard(card);
    20.     }