UMG and Owning Players Pawn, when is it valid for joining players?

Hey i was hoping someone can give me some advice on UMG.
Atm am hooking up gameplay systems to my UI and all good until i start testing it under difrent conditions.

Now server side / in editor (PiE) it is working fine and when spawning in UI e.g: Health Bar is updated to show correct value.
But for clients the Pawn for the controller is not valid at the time My extended HUD class creates HUD/UI Widgets.
So when the client player is spawned and loaded in, the value is not set and wrong value is displayed for progress bar.

Can anyone tell me when i can safly assume that the controller possesing the pawn is done and is valid?
On Possessed, Begin Play for both the character itself or in the controller don`t do the trick.

I did find a work around and updating the value in the Tick Event for the widget.
But it be realy nice to know if there where a event or place in the call chain where Controller, Pawn and HUD is all valid.

Thanks for any advice on the matter.


Normally, you should be able to get your values from binding the variable in your UMG, and it wont need to be placed anywhere in a tick or otherwise and itll update as the value of the variable updates.

But for your purposes, I wouldnt store your health info on your pawn, as it will give functionality your experiencing, as well as wont replicate without extra functions.
But if you stored it in your PlayerState, this is created BEFORE your pawn is, as each PlayerController gets one. Then I would still just bind the variable, or call events from your PlayerState.

But to directly answer your question, you can do an OnRepwith RepNotify for your pawn, which will be called as soon as its replicated and then store your logic in there.

I haven’t tried this, but perhaps overriding AController::OnRep_Pawn works for your purposes. Controller.h:

class APawn* Pawn;

virtual void OnRep_Pawn();

OnRep_Pawn triggers on both the server and the remote client that owns the controller. When it triggers on the remote client as a result of a server-side possession/unpossession, you can assume that the pawn it points to is network initialized (or null when unpossessing).

I haven’t actually tested this, in my own project I spawn a UMG HUD on all clients as soon as the game starts and then try to retrieve the pawn on Tick like you do. This alternative was on my todo list. If you decide to try this, would love to hear if it works. :smiley:

Hey great advice guys thanks a lot! :slight_smile:
I will try the two approaches after dinner and get back to you on the results.


So over-riding the OnRep_Pawn worked perfectly.
Broadcasting the delegate for the health bar once and all is well.

Thanks again!

Woo, thanks for confirming. :slight_smile: