- Home /
Question by
TwentyFourMinutes · May 04, 2018 at 08:53 PM ·
c#networkingrpccommand
SyncListString not changing in a Command
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
Your answer
Follow this Question
Related Questions
Can I use Rpc Calls and Commands on the same object? 0 Answers
SyncListString not changing properly 0 Answers
Unet [command] doesn't get called at all. 0 Answers
Custom Object Visibility (UNet) 0 Answers