Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

CustomProperties values are duplicated in all players

$
0
0
Hi, sorry for my bad English.
I'm using PUN and I face a strange behaviour with custom properties.

I have two players per room. The first is the master and the 2nd the client. When the master enter in the scene "Game" he sets his custom property and get the type "Rouge" (Red in English)....and if it is the client he gets the type "Bleu".

The first time I make them play a party. Everything works fine. Then I make them left the party and create new one by changing the person who creates the room, so the last client become the master and the last master client become the client.

When I get their type sometimes I got Blue for the master and the client, sometimes Rouge for both...But normally it's impossible because of my code


if (PhotonNetwork.isMasterClient) //master client is the first to connect
{
Debug.Log("je suis dans le master");
ExitGames.Client.Photon.Hashtable infoJoueur = new ExitGames.Client.Photon.Hashtable();
//On instancie les infos sur son profil
infoJoueur.Add("type", "Rouge");
infoJoueur.Add("typePlayer", "player");
infoJoueur.Add("wantReplay", "Null");
PhotonNetwork.player.name = j.pseudo;
infoJoueur.Add("pseudo", j.pseudo);
PhotonNetwork.player.SetCustomProperties(infoJoueur);

GameObject profilR = PhotonNetwork.Instantiate(prefabProfilRouge.name, pivotRouge.transform.localPosition, Quaternion.identity, 0);
int view = profilR.GetComponent<PhotonView>().viewID;

GestionInteraction gi = profilR.GetComponent<GestionInteraction>();
gi.majInfoProfil(view,j.pseudo, victoireDefaite, panelAttenteMatchingJoueur);


} else { //we have the 2nd player

ExitGames.Client.Photon.Hashtable infoJoueur = new ExitGames.Client.Photon.Hashtable();
infoJoueur.Add("type", "Bleu");
infoJoueur.Add("typePlayer", "player2");
infoJoueur.Add("wantReplay", "Null");
PhotonNetwork.player.name = j.pseudo;
infoJoueur.Add("pseudo", j.pseudo);
PhotonNetwork.player.SetCustomProperties(infoJoueur);


PhotonPlayer[] listeJoueur = PhotonNetwork.playerList;
ExitGames.Client.Photon.Hashtable infoPlayerRouge = listeJoueur[0].customProperties;
ExitGames.Client.Photon.Hashtable infoPlayerRouge2 = listeJoueur[1].customProperties;

Debug.Log(infoPlayerRouge["type"].ToString() + " " + infoPlayerRouge2["type"].ToString());
Debug.Log(infoPlayerRouge["typeJoueur"].ToString() + " " + infoPlayerRouge2["typeJoueur"].ToString());

PhotonNetwork.room.open = false; //On ne peut plus accéder à la room
PhotonNetwork.room.visible = false; //La room n'est plus listée parmi la liste des room du lobby

}
}
When I display in the else the attribute type of the two players I get, Rouge and Bleu, but when I get theses values somewhere in my code I have Bleu Bleu or Rouge Rouge for the two players...and I don't know how it is possible.

These values are never changed, because I use it to know who is playing....so everywhere i should have when i get my playerList customProperties, Blue and Rouge.

I tried to add another attribute, typePlayer, but I had the same issue. The first type I got player1 and player2...but when I make them leave the room then recreate new one by changing master and client I got the same issue....

Viewing all articles
Browse latest Browse all 15755

Trending Articles