I am running into some issues with the player join callback and network list. This is the only thing that I am loading into the scene right now
using Unity.Netcode;
public class MyNetworkManager : NetworkManager
{
private NetworkList<ulong> ids;
private void Start() {
ids = new NetworkList<ulong>();
OnClientConnectedCallback += (ulong playerId) => {
print(playerId);
ids.Add(playerId); // this is where I get error
print(ids.Count);
};
StartHost();
}
}
The error that I get is
NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.NetworkList`1[T].Add (T item) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/NetworkVariable/Collections/NetworkList.cs:377)
MyNetworkManager.<Start>b__1_0 (System.UInt64 playerId) (at Assets/Scripts/Managers/MyNetworkManager.cs:12)
Unity.Netcode.NetworkConnectionManager.InvokeOnClientConnectedCallback (System.UInt64 clientId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Connection/NetworkConnectionManager.cs:46)
It’s longer but I don’t think anything below that is necessarily relevant. I think this has got to do with how the callback sets up the network list up to fail since everything runs fine if I just don’t add it id (or anything) to the network list.