Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

NetworkManager PlayerPrefab Reporing Empty

Discussion in 'Multiplayer' started by SkrillKill, Feb 10, 2017.

  1. SkrillKill

    SkrillKill

    Joined:
    Jan 15, 2017
    Posts:
    1
    For some reason tonight, after making a change to my Player prefab, the NetworkManager continues to throw this error:
    The PlayerPrefab is empty on the NetworkManager. Please setup a PlayerPrefab object.
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

    On the network manager, my Player prefab is set as the prefab object:



    netmanagerplayerprefab.PNG

    And here is my player prefab (root game object).

    playerprefab.PNG



    And here is the only code associated with making a network connection:

    Code (csharp):
    1.  
    2.  public InputField hostIP;
    3.     public InputField hostPort;
    4.     private int port;
    5.     private string ipAddr;
    6.    
    7.     public void tryToConnect()
    8.     {
    9.        
    10.         port = int.Parse(hostPort.text.ToString());
    11.         ipAddr = hostIP.text.ToString();
    12.  
    13.         NetworkManager.singleton.networkAddress = ipAddr;
    14.         NetworkManager.singleton.networkPort = port;
    15.         Debug.Log(ipAddr);
    16.         Debug.Log(port);
    17.  
    18.         try
    19.         {
    20.             NetworkManager.singleton.StartServer();
    21.             NetworkManager.singleton.SetMatchHost("myHost", 443, false);
    22.             Debug.Log(string.Format("Current Matchhost: {0}", NetworkManager.singleton.matchHost));
    23.             NetworkManager.singleton.StartMatchMaker();
    24.             NetworkManager.singleton.StartClient();
    25.  
    26.            
    27.         }
    28.         catch (Exception e)
    29.         {
    30.             NetworkManager.singleton.StopClient();
    31.             Debug.Log(e);
    32.             UnityEditor.EditorApplication.isPlaying = false;
    33.         }
    34.     }
    35. }
    36.  
    It's very, very early in development hence the very basic connection that could (and will) be done differently. Anyways, why am i getting the error message when the playerPrefab is populated?
     
    Wavo likes this.
  2. aelex_91

    aelex_91

    Joined:
    Mar 13, 2018
    Posts:
    1
    Did you solve this? Got the same error.. :/
     
    Wavo likes this.
  3. Wavo

    Wavo

    Joined:
    Jan 19, 2019
    Posts:
    2
    Me too