This is the blueprint in the UMGwidget which is supposed to fire every tick since it’s supposed to receive the updated float each tick but actually never fire :
Your reply made me realized that I needed to do that.
I don’t know if the way I did it is the correct way but it works so far.
If there is a better way of doing this let me know I would be very interested
Glad to hear that you found the fix. Well, one thing to keep in mind is that the “Get All Actors/Widgets” type nodes are expensive. Using it at Event Begin Play as you’ve done here is not going to cause an issue, but if you come across a situation where you’d have to call them a lot during gameplay, then it is usually better to store a variable that can be used directly.
Apart from that, I’d suggest making the HUD interface call from the blueprint where you created the widget. For example, let’s say you created your Main UI HUD widget in your Player Controller blueprint. Then it would be better to store a widget reference here and have all update calls for the widget to be done through this one variable. So you can just get your Player Controller, and either ask it for the variable or have it call the necessary function.
When you do it this way, you know that you have the right variable as opposed to Get All Widgets with Interface which can potentially provide duplicate copies if someone in your team accidentally created a duplicate Main UI Widget elsewhere.
I’m sorry i’m very new, I’m not sure how I would make a hud widget in my player controller blueprint, like in the screenshot is my best guess
But most importantly i’m running into another issue ! I’m trying to get the reference from an actor in the world to my mainUI_HUD and the get all widget from class doesn’t work.
But when I use get all actors of class and get MyPlayerState it works.
If you could explain to me why this actor can’t seem to do it, it would be very helpful for my understanding
The Widget Component you saw in the dropdown list is actually a component for displaying widgets in the 3D world. Since we’re not interested in that, what we’re looking for is the “Create Widget” node, which I’m assuming you’ve already added somewhere in your blueprints. You can instead use that node to create and then store a reference to your widget in your Player Controller or Default HUD (not widget) blueprint, like this:
As you can see below the Event Begin Play, I have another event for updating the Score. Whenever the score is updated in some other blueprints, they call this event with the new score information. And we can then use the widget reference to update the UI with the new score.
So essentially, we’re saying that no other blueprints need to worry about widget references. All they have to do is tell your player controller blueprint (which is accessible from everywhere using GetPlayerController node) that some value has been changed, and the rest will be taken care of from here.
As for your actor unable to get a widget reference, it might be possible that the actor’s Event Begin Play is being executed before the widget has been created. So try adding a small delay of 0.2 seconds before calling “Get All Widgets of Class”.