PlayerName Bug
Options
Hello guys!
I'm doing a multiplayer game but I'm having a issue with the playerName when several players are conected in the game.
When I run the game in my computer with a local client, the name above the caracter is right but, when I ask my friends to test it, the other characters are displayed with the name the user chose for themselves.
Here is my code:
public class NicknameController : Photon.MonoBehaviour {
bool alreadyRegistred = false;
public Button createBtn;
public GameObject nicknameInputObj;
public InputField nicknameInput;
public Text nicknameText;
void Awake()
{
CheckRegister();
createBtn.interactable = false;
}
void CheckRegister()
{
if (!alreadyRegistred)
{
nicknameInputObj.SetActive(true);
}
else
nicknameInputObj.SetActive(false);
}
public void NicknameInputChange () {
if(nicknameInput.text.Length >= 2)
{
createBtn.interactable = true;
}
else
{
createBtn.interactable = false;
}
}
public void CreateNickname()
{
PhotonNetwork.playerName = nicknameInput.text;
alreadyRegistred = true;
nicknameText.text = PhotonNetwork.player.NickName;
}
}
It seems to be something simple, but I can't figure it out
I'm doing a multiplayer game but I'm having a issue with the playerName when several players are conected in the game.
When I run the game in my computer with a local client, the name above the caracter is right but, when I ask my friends to test it, the other characters are displayed with the name the user chose for themselves.
Here is my code:
public class NicknameController : Photon.MonoBehaviour {
bool alreadyRegistred = false;
public Button createBtn;
public GameObject nicknameInputObj;
public InputField nicknameInput;
public Text nicknameText;
void Awake()
{
CheckRegister();
createBtn.interactable = false;
}
void CheckRegister()
{
if (!alreadyRegistred)
{
nicknameInputObj.SetActive(true);
}
else
nicknameInputObj.SetActive(false);
}
public void NicknameInputChange () {
if(nicknameInput.text.Length >= 2)
{
createBtn.interactable = true;
}
else
{
createBtn.interactable = false;
}
}
public void CreateNickname()
{
PhotonNetwork.playerName = nicknameInput.text;
alreadyRegistred = true;
nicknameText.text = PhotonNetwork.player.NickName;
}
}
It seems to be something simple, but I can't figure it out
0
Comments
-
You take the local player name and assign it, but you need the Player Name from the PhotonView.
Thats as an example from my Photon Example Project https://github.com/SradnickDev/Photon-Example/blob/master/Assets/HealthBarHandler.cs
Look at the start mehtod0 -
Hey I't worked! I knew it was something simple that I was missing.S_Oliver said:You take the local player name and assign it, but you need the Player Name from the PhotonView.
Thats as an example from my Photon Example Project https://github.com/SradnickDev/Photon-Example/blob/master/Assets/HealthBarHandler.cs
Look at the start mehtod
Thank you very much!0