In order for my component to get the correct data and push to the widget, I need to add a delay node when I initialise it.
Here I push the current stamina upgrade value to a widget that updates on the players HUD and it should increase the size of the stamina bar. I use near enough the same logic on my health bar, also with a delay. I know the delay node is not ideal for multiple reasons, any suggestions for this?
You should be using a class based on AHud to drive ui logic. It’s there for a reason. Create your custom hud bp, set it in your game mode and then you can use get player controller → get hud → cast it to your hud bp or use an interface and call the needed init logic.
Like so? Because it doesn’t make any difference. I did already have a widget that I call the playerHUD and that drives all my other logic like ammo counters and current weapon etc.
to understand the issue,
the problem is load order, when you call something on BeginPlay that references another object, you don’t know if that other object exists yet.
If you wont want to use a delay (which is a bad idea) you’d have to validate your dependencies or have an Init function that you call instead of BeginPlay when you know the required things are ready