I’m using the new networking system and I can’t really figure out how to display each player’s name for all clients. The problem is that each client does not see the other clients name. I’m using these methods:
public string playerName;
public override void OnStartLocalPlayer()
{
playerName = PlayerPrefs.GetString("PlayerName");
// Give the server my name
CmdProvideName(playerName);
}
[Command]
void CmdProvideName(string name)
{
playerName = name;
// Broadcast to all clients
RpcPlayerName(name);
}
[ClientRpc]
void RpcPlayerName(string name)
{
playerNameUI.GetComponent<Text>().text = name;
}
void Update()
{
// Keep the name updated for incoming connections
RpcPlayerName(playerName);
}
What’s a good way to approach this? Thanks in advance!