i have a zombie killing game and inside the character BP there is a variable called ZombiesKilled which, well stores the amount of zombies killed by the player and then is replicated so the other players know how many kills you have
should i start using the blueprint Player State instead of doing this inside my character BP? what are the pros and cons?
when the player shoots it sends the info to the server, the server deals the damage to the enemy and then if it died it increments the integer value zombiesKilled that then is replicated back to the player
First off, if you plan to re-spawn the character (destroy and re-spawn) or posses another pawn (spectate or enter a vehicle) you will loose your score so you may be tempted to move the zombiesKilled in the PlayerController…
But… If you move to the PlayerController (it is replicated) you will have a problem because although the server has instances of all PlayerControllers, each client only has his own PlayerController and will not be able to get the data from the other clients unless you go through the GameState.
PlayerState on the other hand is not only replicated on the server but it is also kept up to date on all clients so it you will have no problem keeping the score when you re-spawn and you’ll have access on all clients. It is also kept until the player disconnects do you can transfer the score in other GameModes (like main menu for example).