I want to know how to change the value of a variable inside our player state ?
I need to make the player be able to use button (Widget hud) to change the “integer” inside the player state. I can’t find a way !
(All event work when this variable is egal to a number. I already try it)
Well thats odd i thout player state go exposed to blueprint, but it’s not much exposed. After search i find you can get player state array from game state:
You know how to access varables in blueprint? you grub a link of specific object and drop it and in node list there will be varables category and it will find get set nodes for all public variables.
But then you will have hard time to trying to tie player state with specific player as you only find all player states and there is no variable or function from PlayerState exposed. This most likely will require C++ work or you put in your PlayerState something that allows to distinguish players in them and manually track which player state belongs to whom (for example attach it to PlayerController which copy should be in client memory). You might also consider feature request in feedback forum for more Game and Player State exposure as Game state is also under develop in blueprints
You can create your character and change hairstyle, color skin color etc…
It already work with the Game Instance variable. But in a multiplayer it don’t really work cause each client see is own choice and not the other client choice for their own character ( I mean, if you got pony tail, all the players got pony tails)
So, I try to make the variable host on server for each player controller.
I don’t know if I’m on the right way but it’s almost done !
You can get the PlayerState of a specific player either from their controlled pawn or their controller. In that case both of them have a valid reference to a PlayerState variable which you just need to cast to your custom type.
There is also the possibility of getting all player states via the game state instance. You can get this object basically inside every blueprint by calling the GetGameState node. Inside it there is an array of PlayerStates which holds all playerstates.
Don’t post comments as anwser, but for some reason i can’t move your anwser as comment to my anwser.
Ask yourself if other clients really need to access that information. that information is needed only for creation of pawns and those are spawn by server and he got access to all PlayerControllers. When server spawns pawn that data won’t be needed any more as apperence that will be in pawn and it will be replicated to other clients