Cannot join Internet Match
Hi, i created a simple Unity matchmaking project (see the link at the end for the complete project) in which player is instantiated and their respective names are shown above their gameObjets. The problem is when i create the match it works fine and loads the scene, instantiates the player from prefab, shows the name Everything is looking good. But when on another build i join the same match First of all it takes too long and then simply disconnects and fails to join the match and thows the following error:
MatchMakingClient DropConnection :https://mm.unet.unity3d.com/json/reply/DropConnectionRequest UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
followed by:
ClientDisconnected due to error: Timeout UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
and when i again try to find the match there is no match The match just disappears but on the other build everything is still good !!!????.
I am using Unity 5.5.0f3
Here is the Link to the project: http://www25.zippyshare.com/v/itzvxmq6/file.html
This is the player script:
Player.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Networking;
[System.Serializable]
public class PlayerData
{
public string myName;
public GameObject myObject;
public PlayerData(string n, GameObject g)
{
myName = n;
myObject = g;
}
public PlayerData()
{
}
}
public class Player : NetworkBehaviour {
private PlayerSetup playerSetup;
[SerializeField]
private GameObject myCanvas;
[SyncVar]
public string myName = "PLAYER";
[SerializeField]
Text nameText;
[SerializeField]
private float speed = 2f;
[SerializeField]
RectTransform myTransform;
[SerializeField]
private GameManager gameManager;
PlayerData myData;
void Start()
{
myCanvas = GameObject.FindGameObjectWithTag("PlayerCanvas");
gameManager = FindObjectOfType<GameManager>();
if (isLocalPlayer)
{
playerSetup = FindObjectOfType<PlayerSetup>();
myData = new PlayerData(playerSetup.playerName, gameObject);
CmdPlayerHasJoined(myData);
GetComponent<Image>().color = Color.blue;
nameText.color = Color.green;
}
else
nameText.color = Color.red;
nameText.text = myName;
transform.SetParent(myCanvas.transform);
}
[Command]
public void CmdPlayerHasJoined(PlayerData myData)
{
RpcPlayerHasJoined(myData);
gameManager.players.Add(this);
gameManager.playersName.Add(myName);
}
[ClientRpc]
public void RpcPlayerHasJoined(PlayerData myDataa)
{
myName = myDataa.myName;
nameText.text = myName;
gameManager.players.Add(this);
gameManager.playersName.Add(myName);
}
void Update()
{
if (!isLocalPlayer)
return;
Vector2 move = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
myTransform.Translate(move * speed * Time.deltaTime);
}
}
This is the player setup script:
PlayerSetup.cs
using UnityEngine;
using UnityEngine.UI;
public class PlayerSetup : MonoBehaviour {
public static PlayerSetup instance;
public string playerName = "PLAYER";
[SerializeField]
private Text playerNameInput;
[SerializeField]
private GameObject networkHud;
void OnLevelWasLoaded()
{
if(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Menu")
{
Button setButton = GameObject.Find("SetButton").GetComponent<Button>();
setButton.onClick.AddListener(SetPlayerName);
setButton.onClick.AddListener(SetPlayerName);
playerNameInput = GameObject.Find("PlayerNameText").GetComponent<Text>();
networkHud = GameObject.Find("NetworkManager");
}
}
void Awake()
{
if (instance == null)
{
DontDestroyOnLoad(this);
instance = this;
}
else
Destroy(gameObject);
}
public void SetPlayerName () {
playerName = playerNameInput.text;
networkHud.SetActive(true);
}
}
Answer by ludos · Dec 14, 2016 at 04:48 PM
i have switched to unity 5.5.0f3 as well and now get the same error with a previously working networking setup. however i dont use matchmaking. the client is connected already and it is receiving data, but shortly after it gets disconnected. could be that i am missing something on the server to keep the connection up, or the client would need to send something...
Are you using LAN?
can you also provide your networking scripts so that i can tell whats the issue more efficiently.
Answer by pavan123 · Feb 16, 2017 at 06:58 AM
Hi i am facing the same error: Client Disconnected due to error: Timeout UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() I have this issue when using matchmaker whereby my client kicked off the server approximately 50sec and every time got this error.If you find any solution to resolve that error kindly revert back to me.