Accessing Widget Attached to Actor

Hello, I have a widget that is attached to an actor that shows the current stock of the shelf. I need the value to update on construct so the max value (Current/Max) is to what the shelf will hold, then update the current stock throughout gameplay.

How can I change the max on construct? I tried casting to the actor in the widget but there is no way to get the parent.

Assuming you mean a Widget Component, rather than having the widget pull data out of the actor, consider pushing the data from the actor into the widget. The less logic you pack into the widget, the better:


If you must give the widget access to the owning actor, create a variable of actor type in the widget and set it:

  • the widget can now fetch what it needs from the actor

  • and you can even poll properties via direct comms straight into the widget fields:

The last bit works with nested structs, too:

2 Likes

Thank you for the very detailed reply. I actually ended up doing something very similar to this where I would just go and update the variable that is bound to the widget. Much simpler than I was making it to be.