Better way to do widget binding.

So I was actually wondering what is the more reliable way to do bindings. What I mean by that is right now I am saving a reference to the player in the widget blueprint and updating my variables that way, but sometimes the cast fails and the widget throws an error.

So is there a more reliable way to do the bindings, like updating them from my player blueprint?

P.S. - I am casting to the player using the " On Initialized " Event.

Yes, you don’t need to bind at all.

Create the widget in the player ( it is for the player after all ), so you get a reference to it. When your health changes ( or whatever ), just use the widget reference to update the variable that the health bar is connected to.

The way I have done is that I created a HUD blueprint and added it to the viewport in begin play.

you are saying instead of that add a widget component to the player and add the hud there?

Will there be any scaling issues?

I don’t know why there would be scaling issues with a widget, but not the HUD ( there might be, I’m just saying I wasn’t aware of that ). I’m talking about a user widget, not a widget component.

no no…

he means…
in the Player (f.e. the PlayerController), you use CreateWidget to create a Widget. from there, promote a Variable of the blue output. this is your Widget reference.

if you wanna call a Function or Event in the Widget, simply take your Reference Variable and call your func/event from there.

1 Like

Oh yeah I see what you mean…seems obvious in hindsight now…Thanks.