Sync room for new players issues.

I have a room with items a player can pickup and equip.

When two players (playerA and playerB ) connect and player A picks up an item the player B see the item correctly equiped.

But if Player A connects, pick up an item and then player B connects AFTER the item has been looted, the player B still sees the item in the ground and doesnt see the item equiped in player A.

It looks to me like new players are not being synchronized with the current state of the room and every new player which connects see the room "brand new"

I am not sure how I should approach this issue.

When a player equips an item should update everybody by punRPC? than wont work because new players doesnt exist yet.

How can I solve this issue?

Comments

  • Kurtav
    Kurtav ✭✭
    edited June 2018
    Objects items - add them to the floor using PhotonNetwork.InstantiateSceneObject
    When someone takes them, use PhotonNetwork.Destroy (can only be deleted by the master client)
    Change the characteristics of the hero you are looking at can be tracked using (int)photonView.owner.CustomProperties["Strength"] in the function of Awake or Start
    There is another option to get this player property -
    void OnPhotonInstantiate(PhotonMessageInfo info) { (int)info.sender.SetCustomProperties["Strength"] }
  • Kurtav said:

    Objects items - add them to the floor using PhotonNetwork.InstantiateSceneObject
    When someone takes them, use PhotonNetwork.Destroy (can only be deleted by the master client)
    Change the characteristics of the hero you are looking at can be tracked using (int)photonView.owner.CustomProperties["Strength"] in the function of Awake or Start
    There is another option to get this player property -
    void OnPhotonInstantiate(PhotonMessageInfo info) { (int)info.sender.SetCustomProperties["Strength"] }

    Hello, thanks for your response, can you set a gameObject as a custom property?
  • Kurtav
    Kurtav ✭✭
    edited June 2018
    The properties set the PhotonPlayer class -

    PhotonNetwork.player.SetCustomProperties(new Hashtable { { "ExampleIntProperty", 5} });

    The initialized object of this class can be obtained in the following ways:
    1) PhotonNetwork.player
    2) PhotonMessageInfo info - info.sender
    3) photonView.owner
    4) PhotonNetwork.playerList
    5) callbacks - OnPhotonPlayerConnected,etc.

    In PUN classes - GameObject class is not associated with the PhotonPlayer. The GameObject in the Unity scene can be associated with the PhotonView class. Through which we can find the player's data. For example its property. (photonView.owner)