Getting widget

How can I get the existing widget?

I try to change the state of the image inside this widget, but the game tells me “Accessed None trying to read property Image_25”

Can you show us how did you get that reference? (Wait you already did)

I didn’t quite get what’s going on with changing the visibility though, there are multiple ways of switching the image inside a widget, but I don’t think setting the visibility would be the way to go for such a task. You also mentioned that @Nawrot so maybe there’s something I’m missing here, please let me know if that’s the case.

@Ravein, here is a tutorial on switching a widget’s image from the character blueprint (which I think is what you’re looking for), and here is another one on switching images on widget actions.

Hope these suffice to clarify the process :blush:

You turn that image_25 into variable (tiny checkbox next to name in top right part of screen). THen you can directly use its reference.

And if you cannot make that directly:
-create custom user widget in your case whatever is in Target widget

  • when widget is created get reference to that image 25 and put it into normal variable, expose that variable to be visible
  • then place that target widget inside other widgets, and it should have properly working image_25 reference

Ok i did it this way. Still not sure how to get exisiting widget not in file where that widget created

Could you clarify what you mean by that?

I tried to get the Aim widget and its inside - image 25, which I wanted to hide and then show again. But trying to find the widget turned out to be difficult for me, so I decided to just call it directly in this function

Oh your objective was to hide / show the image :rofl: I get it now.

No you’re currently doing it the right way :innocent:
You can’t access something that’s not created. I think that was the issue all along right?

I think i know (or guess) what the problem is.

You open your widget and do blueprint code inside of it. There from inside of widget you can change image_25.

Do not do code changing stuff inside widgets in other places. Well not directly, use blueprint communication methods.

You can make HUD widget, (or player pawn or player controller will do). Then it that hud widget you make dispatcher that sends data needed (like HP, mana etc) then widgets hook to dispatchers and read/update that stuff.

For changing image etc, you code that thing inside widget (like creating texture reference variable and exposing it), then you add some code that replaces texture inside widget.

Well best would be if you followed some tutorials, my rambling here about all communication with widgets is not optimal to learn from. :slight_smile:

1 Like