Client Playerstate in HUD sometimes invalid

Hi!

im trying to get playerstate in my HUD’s BeginPlay(). Sometimes, in PIE multiplayer with multiple players, playerstate is invalid.

This problem never occurs server-side. With 2 players it does sometimes (maybe 1 of 10 times) on clientside.
With 10 player it occurs every time with every player.

I can reproduce this problem in a new project (with startercontent).
Just add a new HUD BP with this:

Im probably doing something wrong, but what am i missing? Thanks for you help!

EventBeginPlay might be too early to access a playerState. in your GameMode blueprint, you can use EventPostLogin() to know when a player is finished being set up properly, so it should have a playerState by that point.

Im using EventBeginPlay from inside my HUD Blueprint to display some information.
Afaik EventPostLogin() in GameMode is not available client side (Gamemode runs only on server).

Im thinking i could display some dummy information in HUD/EventBeginPlay. Then when EventPostLogin in GameMode fires i send some signal back to the client to update this information.

Im at work right now. I’ll give it a try in about 7 hours.

I tried a lot of things today… most of them did not work.

In EventPostLogin() i send a signal back to the connected client - PlayerState was still invalid.
Then i tried EventBeginPlay() in HUD, Playerstate, GameMode, PlayerController, GameState, PlayerPawn - Payerstate was always invalid.

Kind of strange that in EventBeginPlay() in PlayerState the Playerstate was invalid.

But i found something that worked. Its EventTick() in Playercontroller. Looks like a hack:

I feel dirty now -_-

The reason behind this might be that playerstate is replicated and it just takes some time to arrive at the client.

i did a similar thing, but instead of using PlayerController’s EventTick() i kept checking for it in myHud’s EventRecieveDrawHud():

I was hoping EventPostLogin() would work, but i guess the PlayerState just shows up late without letting anyone know.

I ended up doing it your way. Thanks for your help!