0
votes

I am working on simple multiplayer (2-player so far) game based on built-in Network Manager (based on this great tutorial https://unity3d.com/learn/tutorials/s/multiplayer-networking) and I have absolutely no idea how to solve my problem. Every tutorial I found about scoring systems was focused on local multiplayer game (not using Network Manager).

My question is: How to display both players score on each player's UI in format like [Player1Score : Player2Score] if I store player's score in their instance of player's prefab (as a field). I would like to display the scores in any way, as separate or as one appended string (UI text).

Any help and ideas are welcome! Cheers!

2

2 Answers

0
votes

Well basically , as far as i know , you firstly need a controller (server side) which keeps the score. Then through Syncvar and RPC you can propagate to clients the score you need. The logic there is at your choice , for example you might use delegates everytime a point is scored (it will depend on your game), and synchronize the variable.

https://docs.unity3d.com/Manual/UNetActions.html

0
votes

I do not know what your case is? But can I suggest using Socket to transfer data between client and server. From there it is possible to display each side's scores to the opponent. Via https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket?view=net-5.0