- Home /
Best way to synchronize game scores?
Hello.
I've got a problem. I've got a authoritative server based game, and I want to sync the team scores between players.
I've got 2 options:
1: State sync 2: Buffered RPC calls
I want to have several actions done on score, frag etc. like an anouncer on the clients saying "Blue scored" or "Fragged by PlayerNameHere", but I also want late-comers to get these values.
Thanks.
Use RPCs sending killer, killed, info, and send it when a player is killed, also use rpc's to send data when a OnPlayerConnected(){} But I would not do that with newcomers, and I cannot think of any game does that. For scores, just send to a gameobject, premade in scene with only 1 instance to hold data use RPC calls to send the next kill, and use if(Network.isServer){} on OnPlayerConnected(){} to sync to newcomers
Wow, forgot about this question, sorry.
But it WAS very useful to me :)
In fact the game is nearing the first beta, thanks.
I did it as you said, scores are synced with RPCs, called everytime an event happens on the server.
When a client connects, it just sends a request for the current state of the scores, and builds upon those scores.
Thanks again, please convert to an answer so I can vote as solved :)
I tried to do this as well, having one game object as the Game$$anonymous$$anager, with a script attached to it that stores the player scores on as a dictionary . However, whenever I try to call an RPC like RpcUpdateScore( ... ) on this object, I get a NullException error on the clients. It seems like on the clients, they can't find the Game$$anonymous$$anager object. Any tips?
Your answer
Follow this Question
Related Questions
Multiplayer Scoreboard Problem. 1 Answer
Does the position change need state synchronization? 2 Answers
RPC Call Mix Up Issues 0 Answers
Get RPC senders ID, or IP? 1 Answer