Search Unity

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

    Launceleyn

    Joined:
    Dec 10, 2021
    Posts:
    1
    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):
    1.  
    2.    
    3.    [Command]
    4.     public void CmdDealCards()
    5.     {
    6.        
    7.        
    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);
    18.        
    19.        
    20.     }
    21.