Getting a NullReferenceException on NetworkManager only in standalone when spawning Player Objects

Hello guys,

Im having some problems with my NetworkManager and NetworkLobbyManager.
When I start my program in the editor, everything works perfectly. If I start it however over a Standalone, I get the following NullReferenceException:

NullReferenceException: Object reference not set to an instance of an object
  at UnityEngine.Networking.NetworkTransform.SerializeMode3D (UnityEngine.Networking.NetworkWriter writer) [0x00062] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkTransform.cs:256 
  at UnityEngine.Networking.NetworkTransform.OnSerialize (UnityEngine.Networking.NetworkWriter writer, Boolean initialState) [0x0006f] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkTransform.cs:200 
  at UnityEngine.Networking.NetworkIdentity.UNetSerializeAllVars (UnityEngine.Networking.NetworkWriter writer) [0x00015] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:451 
  at UnityEngine.Networking.NetworkServer.SendSpawnMessage (UnityEngine.Networking.NetworkIdentity uv, UnityEngine.Networking.NetworkConnection conn) [0x000f2] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1393 
  at UnityEngine.Networking.NetworkServer.ShowForConnection (UnityEngine.Networking.NetworkIdentity uv, UnityEngine.Networking.NetworkConnection conn) [0x00013] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1190 
  at UnityEngine.Networking.NetworkConnection.AddToVisList (UnityEngine.Networking.NetworkIdentity uv) [0x00010] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:551 
  at UnityEngine.Networking.NetworkIdentity.AddObserver (UnityEngine.Networking.NetworkConnection conn) [0x000f0] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:842 
  at UnityEngine.Networking.NetworkServer.SetClientReadyInternal (UnityEngine.Networking.NetworkConnection conn) [0x00104] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1143 
  at UnityEngine.Networking.NetworkServer.SetClientReady (UnityEngine.Networking.NetworkConnection conn) [0x00007] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1105 
  at UnityEngine.Networking.NetworkManager.OnServerReady (UnityEngine.Networking.NetworkConnection conn) [0x00029] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:1009 
  at UnityEngine.Networking.NetworkManager.OnServerReadyMessageInternal (UnityEngine.Networking.NetworkMessage netMsg) [0x0001e] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:853 
  at UnityEngine.Networking.NetworkConnection.InvokeHandler (Int16 msgType, UnityEngine.Networking.NetworkReader reader, Int32 channelId) [0x00086] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:217 
  at UnityEngine.Networking.NetworkServer.InvokeHandlerOnServer (UnityEngine.Networking.ULocalConnectionToServer conn, Int16 msgType, UnityEngine.Networking.MessageBase msg, Int32 channelId) [0x0003b] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1638 
  at UnityEngine.Networking.ULocalConnectionToServer.Send (Int16 msgType, UnityEngine.Networking.MessageBase msg) [0x0000b] in C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalConnections.cs:83 
  at UnityEngine.Networking.ClientScene.Ready (UnityEngine.Networking.NetworkConnection conn) [0x0005b] in C:\buildslave\unity\build\Extensions\Networking\Runtime\ClientScene.cs:287 
  at UnityEngine.Networking.NetworkManager.OnClientConnect (UnityEngine.Networking.NetworkConnection conn) [0x0000e] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:1112 
  at UnityEngine.Networking.NetworkManager.OnClientConnectInternal (UnityEngine.Networking.NetworkMessage netMsg) [0x0007d] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:919 
  at UnityEngine.Networking.NetworkConnection.InvokeHandler (UnityEngine.Networking.NetworkMessage netMsg) [0x0002c] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:228 
  at UnityEngine.Networking.LocalClient.ProcessInternalMessages () [0x000dc] in C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalClient.cs:142 
  at UnityEngine.Networking.LocalClient.Update () [0x00002] in C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalClient.cs:69 
  at UnityEngine.Networking.NetworkClient.UpdateClients () [0x00024] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:950 
  at UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () [0x00006] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:1073 
 
(Filename: C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkTransform.cs Line: 256)

I tried to delete my Libarys Folder and changed my Unity Version from 5.5 to 5.6 Beta, but nothing worked for me.

I have no clue of what im doing wrong and i hope some of you could help me :slight_smile:

I have seen similar issues before and it’s usually due to trying to spawn a prefab, instead of a instantiated object.

playerObject = Instantiate(playerPrefab) as GameObject;
NetworkServer.SpawnWithClientAuthority(playerPrefab, connectionToClient);

Note that here we try to spawn playerPrefab and not the playerObject.