Player 2 OnPhotonSerializeView is updated and Player 1 is not?

Options
I have a script that I use as a game manager which has a view owned by the scene. It holds the value for each player's character and their player ID.

I noticed that when running as first player, I am not able to see the second player's values in the inspector when player 2 updates the player 2 variables. However, player 2 gets player 1's values.

For example, when you first join the room, if you are the master client, the variable p1Username is updated. If you are not the master client, p2Username is updated.

The master client will only seen p1Username being populated. The second player will see p1Username and p2Username populated.

The same thing happens on the character select screen. When the select button is hit, player 1 can only see his own character name in the inspector but the variable for p2username is blank. However, player 2 can see both names populated in the inspector.

Am I missing something? I have the object being instantiated with PhotonNetwork.InstantiateSceneObject("MultiGameManager", transform.position, Quaternion.identity, 0, null);
It has a view object that references the script and is set to unreliable. I've also tried unreliable update and reliable.

What am I missing?

Comments

  • Hi @Kym,

    OnPhotonSerializeView is called on each client, however only the Owner of the current object can write something to the stream, each other client will just read data from it. Because a networked object can only have one Owner, only one client can update the object's data on all clients. In order to let another client write data to the stream, you would have to transfer the object's Ownership to another client. Again: only one client can write data to the stream at the same time.

    I guess something similar to what you want to have can be achieved by using either RPCs or the RaiseEvent function. Since you already have a PhotonView component attached to the object, you could use RPCs in this case.