Delay on PhotonNetork.PhotonViews accessibility?

Not sure what the intended behavior is, but it seems that PhotonNetwork.PhotonViews is not immediately updated when a new player joins the room.

Here is what I see:
- I connect with the master client, all is well
- I connect with client A, all is well
- I connect with client B, then during OnJoinedRoom, I tried to access PhotonNetwork.PhotonViews, but I only see 1 entry, and that is for the master client's PhotonView

Q: since client A has been connected for at least several seconds by now, and it also shows up in PhotonNetwork.PlayerList, why has it's PhotonView component not yet been added to PhotonNetwork.PhotonViews?

Just hoping its a bug and not intended behavior. For now, I am simply delaying calling PhotonNetwork.PhotonViews by 1-2 seconds after clients join the room, and then everything works great. I just hope that I don't need the keep that delay in there.

Thanks in advance!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @BillDozer,

    I don't think this is a bug.

    OnJoinedRoom callback is called when the client receives Join event of the local player. After this event, the client will receive the cached events of network instantiation of previous players already in the room. So the behaviour you see is expected.

    I don't know when it's considered safe to start playing with PhotonViews after joining a room.
    Maybe @Tobias can help here.
  • Thanks again @JohnTube - am I missing a callback for when the views are valid? Can you please point me to any documentation I maybe overlooked to subscribe to some callbacks for when views become valid?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2019
    Hi @BillDozer,

    if the PhotonView is a result of a network instantiation (PhotonNetwork.Instantiate) then there is the callback: IPunInstantiateMagicCallback.OnPhotonInstantiate(PhotonMessageInfo info). Don't forget to register and unregister the class implementing the callback.

    But there is no callback for when ALL network instantiation events have been received (or ALL cached events).
  • Ok @JohnTube this is working thank you very much!