Hello,
I have a question regarding the pun integration and the order of execution for PUN callbacks. Specifically, my question is regarding two scripts: SpawnManagerBase and PunCharacter.
What guarantees that the master client will execute SpawnManagerBase.OnPlayerEnteredRoom() before PunCharacter.OnPlayerEnteredRoom()? It is critical that the master client always executes SpawnManagerBase.OnPlayerEnteredRoom() first, since the remote players need to exist on the new client before PunCharacter.OnPlayerEnteredRoom() tries to send RPCs for them to do things like equip items.
I know that these two OnPlayerEnteredRoom functions are not entirely identical, since one implements the MonoBehaviourPunCallback function and the other is executed with the event handler after the MonoBehaviourPunCallback is hit, but as far as I can tell this doesn't effect the order of execution.
The reason I bring this up is because I created a new script for spawning my AI agents, called AgentSpawnManagerBase, which is quite similar to SpawnManagerBase. I keep track of the PhotonViews (which are the agents) as they are created, and raise a new AgentInstantiation event w/ PhotonNetwork.RaiseEvent when OnPlayerEnteredRoom is called.
This only partially works for creating my agents on new clients, because I can see that PunCharacter.OnPlayerEnteredRoom() is called before AgentSpawnManagerBase.OnPlayerEnteredRoom() which results in the RPC's from PunCharacter failing because the agents do not exist on the new client yet. So you can see how the order of operations is being broken here, but it is unclear to me why the order of operations would be broken for my AgentSpawnManagerBase but not be broken for SpawnManagerBase.
Do you have any recommendations on how this might be fixed to guarantee PunCharacter.OnPlayerEnteredRoom() is alway called before AgentSpawnManagerBase.OnPlayerEnteredRoom()?
I have a question regarding the pun integration and the order of execution for PUN callbacks. Specifically, my question is regarding two scripts: SpawnManagerBase and PunCharacter.
What guarantees that the master client will execute SpawnManagerBase.OnPlayerEnteredRoom() before PunCharacter.OnPlayerEnteredRoom()? It is critical that the master client always executes SpawnManagerBase.OnPlayerEnteredRoom() first, since the remote players need to exist on the new client before PunCharacter.OnPlayerEnteredRoom() tries to send RPCs for them to do things like equip items.
I know that these two OnPlayerEnteredRoom functions are not entirely identical, since one implements the MonoBehaviourPunCallback function and the other is executed with the event handler after the MonoBehaviourPunCallback is hit, but as far as I can tell this doesn't effect the order of execution.
The reason I bring this up is because I created a new script for spawning my AI agents, called AgentSpawnManagerBase, which is quite similar to SpawnManagerBase. I keep track of the PhotonViews (which are the agents) as they are created, and raise a new AgentInstantiation event w/ PhotonNetwork.RaiseEvent when OnPlayerEnteredRoom is called.
This only partially works for creating my agents on new clients, because I can see that PunCharacter.OnPlayerEnteredRoom() is called before AgentSpawnManagerBase.OnPlayerEnteredRoom() which results in the RPC's from PunCharacter failing because the agents do not exist on the new client yet. So you can see how the order of operations is being broken here, but it is unclear to me why the order of operations would be broken for my AgentSpawnManagerBase but not be broken for SpawnManagerBase.
Do you have any recommendations on how this might be fixed to guarantee PunCharacter.OnPlayerEnteredRoom() is alway called before AgentSpawnManagerBase.OnPlayerEnteredRoom()?