Re-send ClientRPC after new player joins

Hi everyone!

I’ve used the old Unity Networking system and this worked like a charm but now Unet appears to not have this feature or I’m doing something wrong.

So I have spawning system working, network transforms working and all that. Now I want to spread across the network some player information (saved locally on each client) to their player counterparts on other people’s clients.

I’m using ClientRpc’s and they work very well for host+client connections, but if I get more players to join after that, they just don’t receive those old ClientRpc’s…

How can I make Unity to re-send old rpc’s to each new client so that they have all the information passed until that point?

Thank you in advance.

PS: This is an example and yes I’m using commands from the clients to the server, and the server calls the rpc.
[ClientRpc]
public void RpcJoin()
{
Debug.Log("I joined! " + playerName);
}

No, they do not work like that. You will have to send a command to the server about the player information, and then the server should set SyncVars accordingly. The updated sync vars will be sent to all players automatically, even the newly joined ones. You can always use hooks to run code on change.

If you deal with arrays, create SyncLists. They work like regular C# lists and can be defined as public SyncListInt theSyncList = new SyncListInt (). They do not need SyncVar attribute. You can also set a callback for it in Awake method, so you will be able to run custom code once state changes.