IndexOutOfRangeException: TanksMP.NetworkManagerCustom.AddPlayer ()



  • Okay, so I have followed your instructions on both Mac and Windows computers builds using Unity 2019.1.13f1
    I tried using 2018 but had issues with the package manager, so lets stick to that.

    When the game starts, it gives array out of bounds errors for the player prefab, like it never set up the player prefab.
    IndexOutOfRangeException: Index was outside the bounds of the array.
    TanksMP.NetworkManagerCustom.AddPlayer () (at Assets/TanksMultiplayer/Scripts/NetworkManagerCustom.cs:323)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <7d97106330684add86d080ecf65bfe69>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <7d97106330684add86d080ecf65bfe69>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <7d97106330684add86d080ecf65bfe69>:0)
    Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:452)
    Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, Photon.Realtime.Player player, System.Boolean encrypt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1044)
    Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Realtime.Player targetPlayer, System.Boolean encrpyt, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2780)
    Photon.Pun.PhotonView.RPC (System.String methodName, Photon.Realtime.Player targetPlayer, System.Object[] parameters) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:459)
    TanksMP.NetworkManagerCustom.OnPlayerEnteredRoom (Photon.Realtime.Player player) (at Assets/TanksMultiplayer/Scripts/NetworkManagerCustom.cs:309)
    TanksMP.NetworkManagerCustom+<WaitForSceneChange>d__18.MoveNext () (at Assets/TanksMultiplayer/Scripts/NetworkManagerCustom.cs:283)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    TanksMP.NetworkManagerCustom:OnJoinedRoom() (at Assets/TanksMultiplayer/Scripts/NetworkManagerCustom.cs:268)
    Photon.Realtime.MatchMakingCallbacksContainer:OnJoinedRoom() (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3556)
    Photon.Realtime.LoadBalancingClient:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2678)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:640)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:544)
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1535)
    Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:116)

    I installed your package first, then photon PUN free 2.....then set it up with my own app id, then ran your setup scripts.
    I opened the Intro scene and press start and its broken.

    Any idea how to fix it?



  • Hello,

    the asset has been submitted with 2019.1.0 as indicated on the Asset Store page, so that is the minimum required Unity version.

    If you open the Intro scene and investigate the Network prefab, it should look like this:

    alt text

    If it doesn't, please drag the player prefabs from your project at TanksMultplayer > Prefabs > Resources in there.

    Hope this helps!


Log in to reply