Struggling to figure out how to change information on the specific client (Or the client’s character or client-related information) based on a Command. For example, I’d like to change a client’s stat only on the commanding client after retrieving it from a database, since they’re the only ones that will be viewing it. While it may be used in equations server-side, no reason for all clients to have access to the information - much like persistent inventory, which is something else that would be initially requested via a Command (As far as I can tell).
I’ve found mention of NetworkServer.SendToClient, but I can’t for the life of me figure out how to use it in a way that would be useful. What I’d rather do, instead of sending the string retrieved from the off-project PHP script (Which doesn’t even seem to be possible with that function - it doesn’t seem to take a string at all), is change all the information from the server and update it for one specific client - the one it’s relevant to. The initial sender of the command.
M’well… from my (Limited) understanding of SyncVar, it’s supposed to sync across all clients… but only one client needs to know about it, and that’s the client that issued the command. So for example, let’s say I want to display a character stat screen, where someone might see Strength and so on in the case of a traditional RPG… these stats don’t need to be sent to all clients because they’ll never do anything with those stats, and frankly don’t need to know what they are.
So, essentially, what I want to do is make it so that those stats get sent to the specific client that requested them via a Command.
For example:
StatScreen() might call CmdStats() which would then set a few stat variables on only that client so they could be displayed to the user.
Ah I see. Yes SyncVars are sent to all NetworkIDentity.observers (which is typically all clients). I do not know of a way to manually remove observers (i.e. have the only observer be the client who needs this information).
What I’ve done (this is LOT work). Re-wrote the SyncVars using messages. Messages allow you to send only to 1 client (or all clients). So if you are really concerned about bandwidth/security you could try this.
Recapping options that I am aware of
1: Remove NetworkIdentity.observers from client(s) who do not need to see SyncVar information. I do not know if this can be done.
2: Use TargetRPC to send information only to 1 client
3: Create your own “CustomSyncVars” Use MessageBase to send information only to 1 client (this is what I do).