unity-game-engineunity3d-unetunity-ui

How to display each player's score [Network Manager]


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!


Solution

  • 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