- Home /
Question by
TwentyFourMinutes · May 04, 2018 at 08:55 PM ·
c#networkingrpccommand
SyncListString not changing properly
Hey, I tried to keep track of all users in my multiplayer game, but when I try to assign new names (string) to the List it will only have the own names in it. I am kinda confused, because it also happend to normal [SyncVar] strings.
This is my code:
public class PlayerManager : NetworkBehaviour
{
public SyncListString Users;
// Use this for initialization
void Start()
{
if (this.isLocalPlayer) CmdNameToServer();
}
[Command]
public void CmdNameToServer()
{
Debug.LogError("Server Call");
string newname = "Player " + Random.Range(1, 100);
Users.Add(newname + "Server");
RpcNameToClients(newname);
}
[ClientRpc]
public void RpcNameToClients(string newname)
{
Debug.LogError("Client Call");
Users.Add(newname + "Client");
Debug.LogError(Users.Count);
}
}
I am using Unity the latest release of Unity, in my case it is 2018.2.0b1.
Thanks for any kind of help!
-Twenty
Comment