Player Character, Player Controller and Player State

I am pulling my hair out trying to figure this out. I honestly can’y believe UE4 has PlayerCharacter, PlayerController, PlayerState, GameState, GameMode and GameInstance. Multiplayer over network is the most confusing thing I’ve ever done as a programmer, mainly because I feel the mechanics in play are so outdated and could definitely be streamlined.

Anyway, frustration aside, I am trying to figure out PlayerCharacter, PlayerController and PlayerState for use in an MMORPG. I finally figured out how to use Sessions. I store my player’s name in GameInstance so it persists through levels. Now I have two main issues:

  • I am trying to use a simple TextRender attached to my PlayerCharacter to display names over the players. No matter what I do, players’ names are always the current player’s name. So player ‘A’ logs in. Then player ‘B’ logs in. On player 'A’s screen, player 'B’s name is ‘A’. On player 'B’s screen, player 'A’s name is ‘B’. If I add a third player, it’s the same deal. How do I make these unique to the player and show that on everyone’s screens.
  • I am trying to get my player’s target’s PlayerState. It looks like all of my PlayerCharacters are using the same PlayerState. When I print the PlayerID from player state, they all have the same PlayerState. What am I missing here? PlayerState seems to make absolutely no sense to me.

I guess a more general question is: Where do I store my player’s stats such as Health, Mana, Strength, etc? I’ve tried PlayerState, but this seems to be shared among all my players.

I’ve also scoured this website for all things are similar, and none make complete sense.

Hey Dan,

Depends how you go about it, personally I would store health on the Player Pawn and replicate that but keep Mana and Strength in the Player State. That way if each type of pawn can have its own Max Health/Health etc but still use the stats from the player. It really comes down to design and how you want the architecture to flow. You could also have the Health in the Player State.

Just remember that there is only one player state per player, but there can be a lot of pawns. (More then the number of players). The server can access all of the players player states however which gives the server the ability to control each persons stats to make sure they aren’t hacking or cheating in any way (Server Authoritative Networking).

You can read more about Gameplay Architecture here:

Would also highly suggest running through this tutorial as it gives you a lot of fundamental knowledge on UE4 Networking (as well as general UE4 C++ Knowledge):

Hi Dan. Did you ever figure out the player names problem? I am having the same problem with players’ HEALTH!