multiplayer-community-contributions
multiplayer-community-contributions copied to clipboard
InvalidCastException: Specified cast is not valid.
this also happen to me. If you have any solution pls tell me.
Try this: UNetTransport, the cast was wrong
Port = (ushort) ((**UNetTransport**) m_NetworkManager.NetworkConfig.NetworkTransport).ConnectPort
The documentation tells us to use this repo for networkdiscovery : https://docs-multiplayer.unity3d.com/docs/migration/migratingtonetcode/#network-discovery
But the code doesnt buid :
I had to change to UNetTransport :
Port = (ushort) ((UNetTransport) m_NetworkManager.NetworkConfig.NetworkTransport).ConnectPort,
and it worked.
and also in the HUD :
and it doesn't work
2022/03/28 22:25:00.635 5498 5520 Error Unity host id out of bound id {255} max id should be greater than 0 and less than {1}
2022/03/28 22:25:00.635 5498 5520 Error Unity UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
2022/03/28 22:25:00.635 5498 5520 Error Unity Unity.Netcode.Transports.UNET.UNetTransport:SendQueued (ulong) (at S:/Unity Projects/Hypnomind/Library/PackageCache/[email protected]/Runtime/Transports/UNET/UNetTransport.cs:142)
2022/03/28 22:25:00.635 5498 5520 Error Unity Unity.Netcode.Transports.UNET.UNetTransport:LateUpdate () (at S:/Unity Projects/Hypnomind/Library/PackageCache/[email protected]/Runtime/Transports/UNET/UNetTransport.cs:63)
2022/03/28 22:25:00.635 5498 5520 Error Unity
2022/03/28 22:25:00.635 5498 5520 Error Unity [./Modules/UNET/UNETNetLibraryManager.cpp line 587]
The discovery uses the UnityTransport. I suggest installing the com.unity.netcode.adapter.utp
package and using the UnityTransport component instead of the UnetTransport that way you don't have to change any code.
Same problem