- Home /
Small RPC Code Not Working
Hello Everyone
i'm in the process of learning networking and RPC's ...
In The MultiPlayer[In Scene 1] Script I Use This Code
void OnPlayerConnected(NetworkPlayer networkPlayer)
{
networkView.RPC("TellPlayerServerName", networkPlayer, serverName);
}
and in other Script Called PlayerGetInfo[In Scene 2]
I Use This Code
[RPC]
void TellPlayerServerName(string servername){
serverName = servername;
}
i'm trying to send Server Name To The Player. but its not working. i rly dont know why.
Toss in Debug.Log("TPSN, sn="+servername);
? Then one in OnPlayerConnected.
What do you mean "{In Scene 2]"? Does the client start in scene 2, and the Server in scene 1? Normal RPCs send to their twin gameObject; either the same scene (or a persistent?)
Answer by whydoidoit · Mar 16, 2013 at 12:02 PM
Probably because your serverName variable in the class has the same name as your parameter so it's never being set.
Try
this.serverName = serverName;
i dont think so.. because its servername not ServerName its not the sane parameter thanks anyway, i tried your code. and still not work
Your answer
![](https://koobas.hobune.stream/wayback/20220613094520im_/https://answers.unity.com/themes/thub/images/avi.jpg)