Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by kosted · Jun 14, 2016 at 09:45 AM · networkingphotonroom

[PUN] Duplicates data in master client and client custom properties

I guys. I face a strange behaviour with PUN. This is my use case : I have two players, ted and kosted.

Let's suppose that kosted creates the room. In the room he sets his custom property and get "type = Rouge". When the 2nd player joins this room get get the "type=Bleu".

 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 get type in the type of the master client I got Rouge, and the type of client is Bleu.

The issue come when i make my two players leaves the room. The ancient client creates a new room and become the master client, and the previous master client joins the room as a client. But when i try to get the custom property type, sometimes i get "Bleu" or "Rouge" for both.

But normally it's not possible, because accoding to my previous code, master client and client doesn't execute the same code. This custom property is never modified in my app, so i don't know how they do to have the same custom property.

Please how could I do ?

@Tobias

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JimmyRage · Jun 16, 2016 at 08:31 AM 0
Share

The problem seems to be in the following lines of code

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

PhotonNetwork.playerList is not the same for all clients. This means that index zero is not always the $$anonymous$$asterClient. You can check this by debug logging the playerList when there is just the $$anonymous$$asterClient and after another player joined the room.

avatar image kosted JimmyRage · Jun 16, 2016 at 01:34 PM 0
Share

I use these lines to check values in custom properties after the connection of the client. In the debug I got Red and Blue...But when I use the same lines of code somewhere in my app, I got Blue Blue or Red Red. That is to say that Photon changed these values automatically...

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Noob problem with Photon 0 Answers

Photon & Unity Question 0 Answers

Photon Network Client Reading empty variables when connect 0 Answers

Photon Join Random CustomRoomProperties not working 0 Answers

Unity - Photon OnJoinedRoom not being called 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges