The code should be identical to what is shown on the video. The userData variable itself is empty so it can’t access the name, will try to see what’s up with that.
I get this error code:
NullReferenceException: Object reference not set to an instance of an object
TankPlayer.OnNetworkSpawn () (at Assets/Scripts/Core/Player/TankPlayer.cs:25)
Unity.Netcode.NetworkBehaviour.VisibleOnNetworkSpawn () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Core/NetworkBehaviour.cs:497)
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.NetworkBehaviour:VisibleOnNetworkSpawn() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Core/NetworkBehaviour.cs:501)
Unity.Netcode.NetworkObject:InvokeBehaviourNetworkSpawn() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Core/NetworkObject.cs:1066)
Unity.Netcode.NetworkSpawnManager:SpawnNetworkObjectLocallyCommon(NetworkObject, UInt64, Boolean, Boolean, UInt64, Boolean) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Spawning/NetworkSpawnManager.cs:636)
Unity.Netcode.NetworkSpawnManager:SpawnNetworkObjectLocally(NetworkObject, UInt64, Boolean, Boolean, UInt64, Boolean) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Spawning/NetworkSpawnManager.cs:539)
Unity.Netcode.NetworkConnectionManager:HandleConnectionApproval(UInt64, ConnectionApprovalResponse) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Connection/NetworkConnectionManager.cs:610)
Unity.Netcode.NetworkManager:HostServerInitialize() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Core/NetworkManager.cs:895)
Unity.Netcode.NetworkManager:StartHost() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.5.1/Runtime/Core/NetworkManager.cs:851)
<StartHostAsync>d__9:MoveNext() (at Assets/Scripts/Networking/Host/HostGameManager.cs:100)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(Lobby)
Unity.Services.Lobbies.Internal.<CreateLobbyAsync>d__4:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:67)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(Response`1)
Unity.Services.Lobbies.Internal.<TryCatchRequest>d__20`2:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:390)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(Response`1)
Unity.Services.Lobbies.Apis.Lobby.<CreateLobbyAsync>d__6:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Apis/LobbyApi.cs:236)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(HttpClientResponse)
Unity.Services.Lobbies.Http.<MakeRequestAsync>d__3:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:47)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(HttpClientResponse)
Unity.Services.Lobbies.Http.<CreateWebRequestAsync>d__7:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:138)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(HttpClientResponse)
Unity.Services.Lobbies.Http.<<CreateWebRequestAsync>b__0>d:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:135)
System.Threading.Tasks.TaskCompletionSource`1:SetResult(HttpClientResponse)
Unity.Services.Lobbies.Http.<>c__DisplayClass0_0:<GetAwaiter>b__0(AsyncOperation) (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent()