Hey all! Still working to wrap my head completely around the new system, gotten a lot of help and hoping for just a tiny bit more! This one is more of a concept question, and I honestly might just be looking in the wrong place for the answer, so any help here would be great!
OK so I’ve got my server and I’ve got my clients, let’s say John, Jason, and Jessie. Clients all log in anonymously (for now!) Which creates a player on the server for each of them. So far so good! Now I want to be able to save inventory items on the cloud save, which I can do but from code that is on the client side, and I would like it to be on the server side. And this is where I’m trying to understand better.
If a player, let’s say John, logins in from the client, is the authentication info sent to the server player object as well? That way I know I am sending items to the right player and not sending John’s items to Jessie.
Like if John’s account info on the Economy service is: XQJ2; when John logs in with the account XQJ2 is that sent to the server? If I want the server to be the one adding items to the Economy back end, how do I link John’s XQJ2 account name to his server player? Does this happen automatically and I just can’t find it, or do I need to send this information somehow? Is there a place in the docs I should be looking?
Does that PlayerId number get sent to the server as well or do I need to do that manually?
For instance if I log in and check on the client side that my PlayerId is JXQ2, does that mean my player on the server will also have the same PlayerId? Or do I need to send that information over to the server and manually set the player on the server to have that PlayerId?
When you refer to ‘the server’, if you are refering to the Unity Gaming Services backend, then NO, you don’t explicitly need to send the PlayerId. When you call any Cloud Save or Economy methods in your game client code, the PlayerId will be communicated to the UGS Backend by the client side Cloud Save or Economy SDK.
If however, you are building your own sever backend and using our Service API to communicate with the UGS Backend, then YES you will need to make sure you use the PlayerId assigned to the client. So, in that case you would need to send the PlayerId to your server.
Gotcha! I’m still working on using proper terminology, but I believe you answered what I was asking. I’ve got a build of the game that can be set as server or client, which is what I’ll need to synch the playerId up with. Sounds like I’ll need to manually send that info from client to server after logging in.
oh small question: If I cam going to send that PlayerId, is it just a string or is it something else?
Is there currently a way for the game server to verify that the client is sending the valid authenticated PlayerId and not pretending to be another player?