I’m currently trying to make it possible for players to create sessions from a lobby. However I can’t create these sessions. I’m using photon fusion with Unity Multiplay services, in particular the matchmaker.
But I can’t get anywhere, even though I’ve copied what they’ve done in their “BR200” project. After contacting Photon support, they told me that they thought everything was fine. So I’m attaching my code for you to have a look and let me know if you find any errors!
Thanks in advance!
Edit : Note that multiplayAssignment is always equal to In Progress until it is equal to TimeOut.
I also get this error on launch: AuthenticationException: Invalid state for this operation. AuthenticationException: Invalid state for this operation. The player is already signing in. linked to this: await AuthenticationService.Instance.SignInAnonymouslyAsync();
However, if I remove the function call I’ll get another error asking me to login
Don’t be fooled. This sort of code isn’t “fine”.
This is decades old C-style programming of a loop which even has literal “loopholes” because you aren’t handling any exceptions. At the least when the service or Internet is down, there will be exceptions and the script will either just stop functioning or keep spamming service calls that keep on failing (and possibly costing you actual money).
Most importantly, are you using Unity Game Server Hosting? If not, Matchmaker won’t work because it currently only works with GSH or Unity Relay.
Hi, sorry it took me a while to reply I hadn’t seen the notification.
Thanks for the feedback on the while loop, which I’ll definitely change in the future, it was in order to quickly test the connections with photon fusion. But could that be part of the problem?
As for GSH, I use it well! I’ve set up Multiplay on my dashboard without any problems and had already done a test without the matchmaker, just photon and Multiplay.
In my experience, sloppy code always causes issues.
There’s a limit to how much you can speed things up by writing sloppy code before it starts to reverse and cause more issues and waste a lot of time. That limit is quickly reached, even just a few lines, at most a few dozen lines. If you find it hard to follow your own code, it needs to be fixed.
Specifically network code requires great care in how you write and test it. I would recommend to structure network code well to begin with, with little hardcoding or shortcuts even for such quick tests.
There’s a number of netcode issues being reported every now and then, and unsurprisingly the weirdest cases are commonly with code that was “just a quick test”. It’s also often hard to read and debug too.
Maybe it’s because of this, but I’m not convinced. I followed a tutorial that did the same thing and managed to get a result.
Moreover, the error: AuthenticationException: Invalid state for this operation. The player is already signing in. linked to this line of code AuthenticationService.Instance.SignInAnonymouslyAsync(); can’t be caused by this as it’s not even in the while.
maybe to help people I’ll post the code I use to start the server with photon. Maybe the problem lies here.
This code executes well, it never goes through OnAllocate but always through the if condition in the start. This code is almost a copy and paste from the Photon BR200 project.
It looks like the Multiplay matcher is what’s getting stuck as you are never getting an allocation back. Is there no error being logged? I’d suggest adding a debug log on the OnError callback that is currently empty so that you can troubleshoot why the Multiplay matchmaker is not working.