I have a splash screen scene. I do the auth checks on this scene and give the user an id. Using the SignInAnonymusly method. But the player can open the same game once again on the same computer and I don’t want that. I want to make a check and if the same player is already in the game on a different client, I want to not be able to connect to the game through the other client he opened.
Thanks in advance.
So, is there a way to do this outside of the Authentication service? Can it be done with a different Unity service?
You can save the signed-in status in Cloud Save.
This sounds like a nice idea until you’re flooded with support requests / refunds because “It says I’m already logged in, how do I stop that?”
If your game uses a server, the server can keep a LIVE list of who is already logged in, to prevent the same account from logging in twice concurrently. Saving that list and relying on it will cause the above problem if there’s ever a situation (crash, net fail, disconnect, etc.) where the server is offline or the client goes offline without clearing that saved entry.
Outside that, there is no guaranteed way of avoiding somebody running two instances of the client software. Two instances to two different accounts. Two machines behind the same NAT IP address. Two virtual machines. There’s just so many permutations, it’s just not possible to guarantee detection of the “bad” behaviour.
Greetings again, for those who will think about this situation in the future, I explain how I solved the problem;
Connect the player to the socket on the custom server on the splash screen. As soon as the socket is connected, make the user online based on the user’s id. If a different client tries to connect to the socket with the same user id, the server will send rejection and the other client will leave the game. Even if the player closes the game forcibly via ALT F4 or task manager, since the socket connection will be broken, this information is sent to the server in any way and the server updates the online status of the player by false.
I hope that has been revealing. Thanks everyone, good work!
2 Likes