Question about playerstates

Now, if i understand correctly, playerstate is used to keep track of value for a character(one for each character if multiplayer), suck as name, score, etc.

How do i make my own player state?

I want to create a player state that extends(i think) the current player list so it still has all the other information, but i want to create my own so i can add other things like health and mana. So how do i go about making this?

It is rather easy, you just need to create a new class based off a PlayerState, then specify it in your game mode:


AYourCustomGameMode::AYourCustomGameMode(const FObjectInitializer& ObjectInitializer) 
    : Super(ObjectInitializer)
{
    // ...
    PlayerStateClass = AYourCustomPlayerState::StaticClass();
    // ...
}

As for the health & mana thing, you can add it inside of your newly created PlayerState class as properties.

is right. The same goes for different GameModes / PlayerController (Player -> Game communication) and GameStates, basically any class from UE4, to prevent upcoming questions :smiley:

like this?



ASecretPlayerState::ASecretPlayerState(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	PlayerStateclass = ASecretPlayerState::StaticClass();

}
	


or is PlayerStateclass supposed to be SecretPlayerStateclass. Both give me an error, says it can’t get to Playerstate.h

Also, i have a gamemode class, and i made a blueprint for it too. And inside the blueprint, i changed the playerstate to my custom playerstate. I changed the default Gamemode in the settings too. Is the code the same thing i just did in blueprints? how do i connect a thirdpersonplayer to the gamestate?

As I understand, is Player State only for things you want to travel between clients in a multiplayer game? Like name, score, etc… That way those things show up in a scoreboard for example.

Then things like mana might need to just be in the Pawn if other players never see another player’s mana.

I think back in UDK this was known as the PlayerReplicationInfo but PlayerState.

It holds things like skill levels and inventory too. And people will eventually be able to see your mana and health