问题
I've been getting constant UNet dropouts for a basic networked scene (two player transforms and the occasional RPC). The connection drops due to a timeout.
Connections reliably drop within 5 minutes, and mostly within 30 seconds. I've read online that UNet does this a lot. I've tried increasing the NetworkDropThreshold
and OverflowDropThreshold
up to 90%. I also put the ping timeout up to 5 seconds.
Any ideas on how to fix it? I'm using wi-fi for both players, and I'm on Unity 5.6.0f3.
回答1:
I've tried increasing the NetworkDropThreshold and OverflowDropThreshold up to 90%. I also put the ping timeout up to 5 seconds.
This indeed is a big problem that has not been fixed for over a year or so. Unfortunately, you haven't tried everything yet. There are few things left that can fix or reduce the disconnect rate.
Increase the NetworkManager.maxDelay to about 0.2f
. According to the do documentation, the default value is 0.01f
. Keep increasing it until it stops disconnecting.
If you are using Unet's matchmaking system, that could be the problem because there is a limit imposed on the transfer rate. If you pass that limit, you will be disconnected. Unfortunately, the solution to that is to make your own matchmaking.
回答2:
Upgrading to Unity 5.6.1f1 fixed these issues. While there are no comments in the release notes, or any of the patch notes for the 5.6.0 series, the difference in reliability was astounding, at least for me.
If you're experiencing issues, try the latest version. While the latest stable release worked for me, you can find the latest patch releases at: https://unity3d.com/unity/qa/patch-releases.
If you're using Unity's Matchmaker, there is a hard bandwidth limit that kicks players, and it's expensive. Photon is good alternative for networking: https://www.photonengine.com/PUN.
来源:https://stackoverflow.com/questions/44635674/unet-randomly-disconnects