PlayerRoomIndexing and CustomRoomProperties.
Options
With PUN Classic:
After a recent upgrade to Unity 2019.1.2f and to PUN 1.97 form 1.91, upon creating a room, PlayerRoomIndexing errors twice.
IndexOutOfRangeException: Index was outside the bounds of the array.
ExitGames.UtilityScripts.PlayerRoomIndexing.RefreshData () (at Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs:224)
Any ideas what is going on?
After a recent upgrade to Unity 2019.1.2f and to PUN 1.97 form 1.91, upon creating a room, PlayerRoomIndexing errors twice.
IndexOutOfRangeException: Index was outside the bounds of the array.
ExitGames.UtilityScripts.PlayerRoomIndexing.RefreshData () (at Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs:224)
Any ideas what is going on?
0
Comments
-
bump0
-
Could really use some help on this one folks.
To replicate.
1. Make a scene with an empty game object named PlayerRoomIndexing. Add the script found at Photon Unity Networking>UtilityScripts>Photon Player>PlayerRoomIndexing to the object.
2. Create a new Room with:RoomOptions roomOptions = new RoomOptions(); roomOptions.IsOpen = true; roomOptions.IsVisible = false; PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
PlayerRoomIndexing will error twice immediately with the above error.
IndexOutOfRangeException: Index was outside the bounds of the array.
ExitGames.UtilityScripts.PlayerRoomIndexing.RefreshData () (at Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs:224)
This corresponds to this line.
_playerIds[_entry.Value] = _p.ID;
Commenting out the vestigal: Debug.Log("Entry; "+_entry.Key+":"+_entry.Value);
above this yields a Key of 1 and a value of 0
0 -
Found the issue. This routine requires the MaxPlayers property for a room be set. This should be documented in the code.0
-
Hi @Spektre,
it looks like it's the case yes.
sorry, we didn't explicitly state this in the documentation.
can you try replacing line 209 in "Assets/AssetStorePackages/Photon Unity Networking/UtilityScripts/PhotonPlayer/PlayerRoomIndexing.cs":_playerIds = new int[PhotonNetwork.room.MaxPlayers];
withint count = PhotonNetwork.room.MaxPlayers; if (count == 0) { count = PhotonNetwork.room.PlayerCount; } _playerIds = new int[count];
this fix may work even with MaxPlayers = 0.
please try and let us know.0