How to get Player State reference in UI Widget Blueprint graph?

I am trying to bind some of my HUD interface to the current player PlayerState variables but I can’t seem to find a way to get a reference to my custom PlayerState from the widget blueprint graph.
It works just fine using character variables which I can get using GetPlayerCharacter but since I moved some of the variables to the PlayerState I need the PlayerState.
Am I misunderstanding something? As far as I know the PlayerState is replicated and should be accessible locally.

How about this:

340109-screenshot-2.png

This is indeed how it should be done. This is what I was trying and it was failing but for some reason If I delay it by a fraction of a second it works just fine. I think it is because the widget constructor is executed before the player state is instantiated. It fixes my issue for now but doesn’t feel like a great fix.

340110-capture.png

It is not, but if it works…

I know this is kinda of old. But the player state, for what I tested, is loaded in a different order when you are the client vs server.
Also, as you are trying to get the player state from the widget, depending on where you created your widget, that class can load before the player state (for example, if you are creating inside the player controller). In a blank project, I tested printing a string on both construction script and begin play, this is the order they were printed in the construction script:

Server : GameMode - Game State - Player Controller - Player State - Player Character
Client (Server Version) : Player Controller - Player State - Player Character
Client (Client Version) : Player Controller - Player Character - Game State - Player State

4 Likes

Making this macro helped me. I’m not sure if this is 100% the way but it waits and loads the player state when avaliable.