Download

Define player state class for a multiplayer game

Hello guys!

I’m trying to put all the replicated attributes (like player health, name, etc) to a custom player state class and I have two questions!

  1. Is this good practice? I believe it is since the player state is replicated?
  2. How can I tell UE to use my custom player state class? I’ve read (and saw screenshots) that you define it in the same place you define game mode and other classes, when you press the little arrow to display the custom fields. I don’t have this little arrow… Is there an other place to define the class that should be used?
    I’m using UE 4.7.3

Thanks!
Nico

nevermind it was in the gamemode class default. I must have missed it!
it’s weird that you can’t access it throught the world panel though…

I’m still unsure I’m doing the right thing by putting everything in the player state.
For example I was doing some repNotify when a value changes and it would affect the player’s mesh, but I can’t access the player mesh anymore through the player state…

initcharacter.jpg

This is what I did for my game. A variable type Structure with all the stats I need. in Even Begin Play I do as you see in the picture. Same variable also stored in Game Instance class which all me to update the character as long as the game is running. Once closed down the desired stats will be saved to a file which I can load in my next game run.
Hope this helps.

Raed

Cheers Raed! i’ll dig :slight_smile: