0
\$\begingroup\$

It works perfectly when I try to connect locally from my editor to my running build.

But after I start the server on my Android, and try to connect to it from my editor, it time outs:

enter image description here

As you can see, it finds the match, and then tries to join, but it can't.

If I try to do it from a build, the log says the following:

Log: cannot connect after {10} attempt address {::ffff:127.0.0.1:7777}
ClientDisconnected due to error: Timeout

Why does it tries localhost, when I obviously use the Matchmaking system?

When I tried it on 2 Android devices, the same happened.

Ps.: I know that it's going to be depracated, I just want to use it during a short term gift.

Thanks in advance!

Starting Matchmaker in a Start:

networkManager.StartMatchMaker();
networkManager.matchMaker.baseUri = new System.Uri("https://eu1-mm.unet.unity3d.com");

When the MatchScene ("Battle") is loaded:

if (this.isHost)
{
    networkManager.StartHost();
}
else
{
    networkManager.StartClient();
}

And the Play button's handle: (still same component)

public void Play()
{
    networkManager.matchMaker.ListMatches(0, 1, string.Empty, true, 0, 0, OnMatchList);
}

void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matches)
{
    if (matches.Count == 0)
    {
        networkManager.matchMaker.CreateMatch("match", 2, true, string.Empty, string.Empty, string.Empty, 0, 0, OnMatchCreate);
    }
    else
    {
        networkManager.matchMaker.JoinMatch(matches[0].networkId, string.Empty, string.Empty, string.Empty, 0, 0, OnMatchJoined);
    }
}

void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo)
{
    this.isHost = true;
    this.networkId = matchInfo.networkId;
    SceneManager.LoadScene("Battle");
}

void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo)
{
    SceneManager.LoadScene("Battle");
}
\$\endgroup\$
0

1 Answer 1

0
\$\begingroup\$

Since I couldn't fix it under a day, I gave up and switched to PUN, which took me only like 5 hours.

And it was instantly working.

I used these sites:

https://blog.photonengine.com/dev-story-tanks-multiplayer/

https://doc.photonengine.com/en-us/pun/current/getting-started/pun-intro

\$\endgroup\$
2
  • \$\begingroup\$ This answer would be even better if it described what steps you had to take to implement your PUN solution. \$\endgroup\$
    – DMGregory
    Commented May 19, 2020 at 16:00
  • \$\begingroup\$ Updated the answer with the sources I based my refactor on. \$\endgroup\$
    – Tudvari
    Commented May 19, 2020 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .