Multiplayer player mode issue

I don’t know if this is due to MPPM or not, but I have a sneaking suspicion that it is and just want it confirmed, and hopefully a solution to the issue.

I’m attempting my first multiplayer game, just small scale prototype at the moment. Found out that 2023 had this really cool thing where you could have multiple players without building the game. Sounds perfect. But I want to test it with Unity Game Services like Relay and Lobby and I can’t get it to work.

Do I need to build it, do I need that build on a separate computer, is there something I can do here?
I searched the forums, found NOTHING on this. Not surprising considering it’s the bleeding edge. But here I am.

Like you said, this is pretty burning edge, so there are some issues to be expected. When you say that you can’t get it to work can you help clarify what you mean? Are you seeing errors, are you seeing the same user logged in from all the MPPM instances? That will help us narrow down the problem.

The most likely issue is that the players are all using the same authentication ID (aka account). I know there is some code to go around this somewhere in the documentation.

The quickest way to test without adding any code is to build the project. Run the build and play mode in the editor together, and the build should make its own authentication ID separate from the one the editor is using

Alternatively, make a button that calls (C#):

AuthenticationService.Instance.ClearSessionToken()

and press it on one of the players before authenticating.

As I suspected.

Here’s the relevant error message, it seems to be that it’s the same authentication being sent:

Outputting AuthenticationService.Instance.PlayerId; reveals that it is the exact same Player ID being used.

I’m using anonymous authentication => await AuthenticationService.Instance.SignInAnonymouslyAsync()

Ok, I just added this before await AuthenticationService.Instance.SignInAnonymouslyAsync() and that did the trick completely. Thank you! No more waiting for the build to compile!

I’m happy I could help. Just be careful to remove this for actual distribution of your game if you are running it every time your game authenticates the player, otherwise they will lose their account data every time they sign in!

1 Like

Good call. Thanks!

1 Like

My recommendation is that you add something like #if UNITY_EDITOR around the code block so it’ll only be in use when running in the editor.

1 Like