How to get data from master and change the the other player's value accordingly
Hi Friends,
I am still trying to explore PUN2. I am doing research on eye gaze. There are two players (say player 1 and player 2)
What I would like to do is, If I change the options (using the drop-down menu) of eye directions in master (player 1), I would also like to see a change in the eye directions option on the other player (player 2). So, in other words, I want to control the options of the drop-down menu of the other player from the master. Unfortunately, I am not able to do that. I have tried several times. Could anyone give me a hand, please?
This is the code.
// For changing eye directions of Local player
var master = PhotonNetwork.MasterClient;
if (master.IsMasterClient)
{
var eyeDirectionMaster = GetComponent<EyeDirectionMaster>();
eyeDirectionMaster.currentEyeDirection = orientation;
Debug.Log(eyeDirectionMaster.currentEyeDirection);
}
else if (master.IsLocal)
{
var eyeDirectionMaster = GetComponent<EyeDirectionMaster>();
orientation = eyeDirectionMaster.currentEyeDirection;
Debug.Log(orientation);
}
Thanks
IG
I am still trying to explore PUN2. I am doing research on eye gaze. There are two players (say player 1 and player 2)
What I would like to do is, If I change the options (using the drop-down menu) of eye directions in master (player 1), I would also like to see a change in the eye directions option on the other player (player 2). So, in other words, I want to control the options of the drop-down menu of the other player from the master. Unfortunately, I am not able to do that. I have tried several times. Could anyone give me a hand, please?
This is the code.
// For changing eye directions of Local player
var master = PhotonNetwork.MasterClient;
if (master.IsMasterClient)
{
var eyeDirectionMaster = GetComponent<EyeDirectionMaster>();
eyeDirectionMaster.currentEyeDirection = orientation;
Debug.Log(eyeDirectionMaster.currentEyeDirection);
}
else if (master.IsLocal)
{
var eyeDirectionMaster = GetComponent<EyeDirectionMaster>();
orientation = eyeDirectionMaster.currentEyeDirection;
Debug.Log(orientation);
}
Thanks
IG
0
Comments
-
Use a custom room property.
If it changes via the UI on the Master Client, use SetCustomProperties() and set the new value (for a key you have to make up / assign).
https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state#custom_properties0 -
Thank you. I will try to do that0