1
TNet 3 Support / Change player name in OnNetworkConnect or near.
« on: November 11, 2013, 06:56:10 AM »
Hey! i got a script so when he connects to the server it calls "OnNetworkConnect", and that works just fine. But then i want to change the player name in that function, and apparently that wont work
The name is both Guest before and after the change.
Ive also tested making the name change upon start in the menu that loads
And both here returns Guest.
Then i tested making an Coroutine with a delay by 0.1 seconds, then change the name(in the start function of the menu), Then it works just fine! Is it really neccisary to have a delay for changing name of the player?
- void OnNetworkConnect(bool succes, string message){
- if(succes){
- Debug.Log("Playername before: " + TNManager.playerName);
- TNManager.playerName = "ChangedName";
- Debug.Log("Playername after: " + TNManager.playerName);
- loadMenu();
- }
- else{
- Debug.Log("there was an error: " + message);
- onFailedConnection();
- }
- }
Ive also tested making the name change upon start in the menu that loads
- void Start(){
- Debug.Log(TNManager.playerName);
- TNManager.playerName = "ChangedName";
- Debug.Log(TNManager.playerName);
- }
Then i tested making an Coroutine with a delay by 0.1 seconds, then change the name(in the start function of the menu), Then it works just fine! Is it really neccisary to have a delay for changing name of the player?