Hi everyone. I’m working on a multiplayer game. Almost done, but I couldn’t do the scoring system. How can i do it? I’m using 4.24. I have PlayerState but, i want create a scoreboard. All players send score, ping, death etc variables to server and server will list them. Can you help me?
Have the game mode calculate scores on event and store the results in an array or struct. You can then pass the array/struct to each player via gamestate.
My friend, I am inexperienced in Unreal Engine. Can you show me?
If the Individual scores are already set in each PlayerState you just need to make a Widget that can format the scores from GameState->PlayerArray.
Create a Widget and loop through the PlayerArray and extract the scores to view in the Widget
I am asking a lot but can you please send me a sample blueprint?
Something like this.
Create a Scoreboard Widget and place a Vertical Box on it (I named it “Score List Vertical Box”)
Then this Scoreboard creates a PlayerScore Widget for each entry in the PlayerArray.
The PlayerScore widget has two variables Name and Score marked as “Instance editable” and “Expose on Spawn”
PlayerScore uses those variables to Set Text on its Text Widgets.
Afterwards you could create a function that sorts the scoreboard.
My only suggestion to add to this is to limit the scoreboard update rate to once per second. This will reduce network overhead.
Game mode should update its local scoreboard on event. It should then only update the gamestate scoreboard once a second … (tickcount / Hz)
@GarnerP57 my friend, not working. Playername, score and ping not showing. Player name empty, ping and score set as “0”. Child is not added when new player logs in.
Timing is everything when dealing with multiplayer. When are you calling the Create Scoreboard Widget?.
At BeginPlay the PlayerArray will be empty since it haven’t been replicated yet.
Game mode should be filling the array/struct (scoreboard). Passing to gamestate, replicate gamestate to client.
On player join -> update scoreboard -> spawn player -> replicate gamestate.
Little side question with this, how necessary is Gamemode_BP when doing something like this? Couldn’t you calculate scores on Gamestate server side only and then replicate them to the clients? Whats the benefit of doing the calculation on Gamemode_BP?
All rules for your game should be calculated and managed by the game mode.
- Joining / Leaving
- Spawning / Death
- N points for X event … who gets them.
- Who’s winning.
Scoring is generally part of a ruleset.
Game mode only exists on the server. Clients do not get a copy. Think of GameState as a go between. Server (Game mode) -> game state -> client.
As far as I know it doesn’t work the other way around … client → gamestate → gamemode. You wouldn’t want it to regardless. cheating/manipulation etc.
Oh ok good to know. I though you could do the logic on the gamestate that was on server using the “Server Authority” node with the same results as placing logic in gamemode.
For this I make an actor called GameNameGameInfoReplication, replicates to true, and I spawn in every player controller, and on the tick of the GameMode I update them with score, Roles, everything needed. If you want me to explain the process tell me.
I found a solution like this, but the player name is the same for everyone;
I used Unreal Engine’s multiplayer tutorial. “Conencted players” widget works properly in lobby. Score, death or ping different. But, in scoreboard, just all player names and avatars same.
Hey Garner, thanks for the example. but once the widget is open the scores wont be updated if someone scores or anything right with the current setup? I looking for the “correct” way of doing it so would you do this in GameMode and each time something new happens you would call a event update on the scoreboard widget or is it best practise to use a timer once the scoreboard is open and remove the timer when its closed?