Unity UNET Sprite Syncing

Using UNET matchmaking I have player 1 enter, and I assign them a team and set it’s sprite accordingly.

However player 2 joins in the match it always uses the default sprite on the prefab for player 1 in the room. If I send an RPC saying “Hey look Player 1 actually is this sprite” it works but how can I get it to sync when a player enters the room?

Hope that made sense.

Hope this is still relevant.

You could do something like

public Sprite playerSprite;

public override void OnStartLocalPlayer(){
    CmdUpdateSprite(playerSprite.name);
}

[Command]
void CmdUpdateSprite(string spriteName){
    RpcUpdateSprite(netId, spriteName);
}
[ClientRpc]
void RpcUpdateSprite(NetworkInstanceId id, string spriteName){
    ClientScene.FindLocalObject(id).GetComponent<spriteRenderer>().sprite = Resources.Load(spriteName);
}

Note that the Resource and spriteName bit is just a placeholder as in the Manual they recommend not to use the Resource system. For my projects I use a gameObject that holds all sprites.

It’s important though that you just use valid parameters as stated here