Multiplayer Player left room issue

Are you running the latest version of the PUN add-on? I am not able to reproduce that error. If you can tell me how to reproduce it within a fresh project that would be helpful.
 
Yes, I am using the latest version of UCC and the Multiplayer add-on. this issue has occurred a rare cases. but it causes an issue with gameplay if I get the error.
another issue we facing is at the start scene player prefab can't instantiate and sometimes it destroys automatically, we are facing this issue in the editor also.
 
If you can tell me how to reproduce it from a fresh project I can take a closer look at it.
 
when ever the internet is off/ unavailable while playing a gameplay inthe room, player is getting destroyed
and is there any option to rejoin to the same room after Internet is available?
 
That's more on the PUN side of things so I recommend posting on their forum. I haven't messed with the rooms very much.
 
@Justin We're getting the same in public beta testing for our upcoming title too.

Managed Stack Trace:Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.OnPlayerLeftRoom (Photon.Realtime.Player otherPlayer) (at <00000000000000000000000000000000>:0)Photon.Realtime.InRoomCallbacksContainer.OnPlayerLeftRoom (Photon.Realtime.Player otherPlayer) (at <00000000000000000000000000000000>:0)Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at <00000000000000000000000000000000>:0)ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <00000000000000000000000000000000>:0)ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <00000000000000000000000000000000>:0)ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <00000000000000000000000000000000>:0)Photon.Pun.PhotonHandler.Dispatch () (at <00000000000000000000000000000000>:0)Rethrow as AggregateException: Caught 1 exception(s) in methods called by DispatchIncomingCommands(). Rethrowing first only (see above). (Object reference not set to an instance of an object.)Photon.Pun.PhotonHandler.Dispatch () (at <00000000000000000000000000000000>:0)

It'll be hard for you to repro without a lot of people playing. It'll just be something that needs to be null checked properly in the function I think though? Perhaps `otherPlayer` or `photonView` ?
 
Without being able to reproduce it it's hard to say but yes, go ahead and add a null check and let me know if that fixes it.
 
I looked into this error. The only flaw I noticed was that otherPlayer is null checked inside of `if (m_ActorNumberByPhotonViewIndex.TryGetValue(otherPlayer.ActorNumber, out int index))` which doesn't make sense, null check should occur just after the base call I guess
 
We actually ran into this error again and had to take another look at this function. It had the flaw as mentioned in the previous comment but it also had a more serious issue with the loop that is used to update the m_ActorNumberByPhotonViewIndex dictionary. In a 3 player game you can cause the original error to occur fairly trivially by having the 1st client leave the room and then have the 2nd client leave. Due to the index not being updated for the 2nd client it would error out. Here is our version of the function which seems to be holding up:

C#:
public override void OnPlayerLeftRoom(Player otherPlayer)
{
    base.OnPlayerLeftRoom(otherPlayer);

    // Notify others that the player has left the room.
    if (otherPlayer != null && m_ActorNumberByPhotonViewIndex.TryGetValue(otherPlayer.ActorNumber, out int index)) {
        var photonView = m_Players[index];

        // Inactive players may rejoin. Remember the last location of the inactive player.
        if (otherPlayer.IsInactive) {
            if (m_InactivePlayers == null) {
                m_InactivePlayers = new Dictionary<Player, InactivePlayer>();
            }
            var removeEvent = Scheduler.Schedule<Player>(m_InactiveTimeout, (Player player) => { m_InactivePlayers.Remove(player); }, otherPlayer);
            m_InactivePlayers.Add(otherPlayer, new InactivePlayer(index, photonView.transform.position, photonView.transform.rotation, removeEvent));
        }

        EventHandler.ExecuteEvent("OnPlayerLeftRoom", otherPlayer, photonView.gameObject);
        m_ActorNumberByPhotonViewIndex.Remove(otherPlayer.ActorNumber);

        GameObject.Destroy(photonView.gameObject);
        m_Players.Remove(photonView);
        for (int j = index; j < m_Players.Count; ++j) {
            m_ActorNumberByPhotonViewIndex[m_Players[j].Owner.ActorNumber] = j;
        }
    }
}
 
Top