- Home /
RPC call not sending correct data
So I have a variable called uniqueId
containing a Guid object. This variable is used to identify players over the network.
When eather the server is created or a player join we call this RPC method:
networkView.RPC("CreatePlayerSlot", RPCMode.AllBuffered, "Selecting class...", 0, (string) TypeDescriptor.GetConverter(uniqueId).ConvertTo(uniqueId, typeof(string)), Network.player);
This call is being made in both OnPlayerConnected
and OnServerInitialized
and the method being called looks like this:
[RPC]
private void CreatePlayerSlot(string characterClass, int characterLevel, string newUniqueId, NetworkPlayer newPlayer)
{
NetworkUser tempPlayer = new NetworkUser(); // create player
tempPlayer.netID = new Guid(newUniqueId); // assign unique id
tempPlayer.netPlayer = newPlayer; // NetworkPlayer object
tempPlayer.ready = false; // player is ready or not
tempPlayer.active = true; // occupied or not
tempPlayer.characterLevel = characterLevel; // character level
tempPlayer.characterClass = characterClass; // character class
listOfPlayers.Add(tempPlayer);
}
Now what I want to know is, why does the two items in the list have the uniqueId of the server when this is called once when server is created by the host, and once when a player connects as the client? Shouldn't this method be called on both the server and client with the uniqueId provided by the side calling it?
I guess there's nothing wrong with how I do this but most likely something else?
Your answer
Follow this Question
Related Questions
Send Prefab by RPC? 1 Answer
RPC can't send string? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Check bool on another player 1 Answer