Update image widget from an Actor Blueprint

I am looking to update a UI widget picture in relationship with an object that is lookAt by the player

Here the script:
FIRST_PERSON_UI (Designer tab)

FIRST_PERSON_UI (Graph)

From there, I am looking to update the image to update when the player perform a lookAt action at the following actor, so far my problem is I have no idea how to reference the Target to the variable located in the FirstPersonUI

I cant select any image reference and I guess that because I need to get the Target Anchor to reference the FirstPersonUI (but I am not even completely sure of that)

Thx!!!

You are correct, you need to get a reference to the widget you want to change the image on. That is why you are getting those red errors, it needs a target to know where that variable exists. The easiest way is when you create the widget, it returns a reference that you can promote to a variable.

So my understanding is that I already have that set up

I guess I do not fully comprehend the syntax to link it in the target.

256611-poweremiter-2.jpg

There still part of the concept that I do not have a good comprehension.

Your one step closer, but it looks like you have that reference on yet another blueprint, because its asking for another target. Anytime you are accessing a variable to another blueprint you need to first have a reference to that blueprint.

So now you need to plug in a reference to the blueprint that holds the health bar widget variable. Or you need to move this logic over to the blueprint that holds the health bar widget variable.

Do I need to cast to ? (Have no idea how casting works but I can look into it if that the way to do it)

You may or may not need to cast. Casting is just a way of verifying that what you are communicating with is what you think it is. It’s like picking up the phone and calling your friend Billy, when somebody answers the phone and says “hello”, you first ask if this is Billy your speaking to. If yes then now you know you can now call on functions and variables that Billy owns.

So I’m not sure because I would need to see how your blueprints are setup, It may or may not be difficult to get that reference efficiently. It would be easier if you could possible move this image changing logic to the blueprint that creates the widget.

If not, you will need to get a reference to the blueprint that created the widget. Worst case is you may have to do a get all actors of class, this will give you that reference, or maybe a line trace hit, or overlap event is needed.

Depending on how your blueprints are setup you may have a built in function to do this, for instance if the actor is a player, and you need a reference to the player controller you could use the event on possessed, or function “Get Controller”.

My point is that you need some way to get a reference so you can open up communication between these blueprints.

These are foundational things you are going to need to learn to do, and I highly recommend checking out this video by Epics Zak Parrish, it is one of the best tutorials on blueprint communication I have ever seen:

Hope all this information helps! :)

Hey! that 8 days later…
Watched the video 3 times, help a lot

It getting more clear every time so I will probably give it at least one more run.

The thing I find the most tricky still is (as mention in the video) is getting the reference.
Its way easier to get it when its coming from an Event sent from an object after a player action or from the player itself. but as soon as its a third party system then I get a hard time to wrap around the concept.

The video do not really focus on this, its show some ways and say that there a million others ones to do it, yet when its scripting time, I cant figure one :wink:

Any help, video, or good read on this ?

Thank you!

The UI_Widget is created In the FirstPersonChar.
Calling the interface is done by a Blueprint Actor in the GameWorld upon being tag by the player.

I was able to get the Object in the GameWorld tag by the player
I am not able to get that Object Blueprint the reference it need to update the UI_Widget

I guess I could try to move the logic of calling the UI_Widget on the FirstPersonChar, but I kind of find it more rational to have the different GameWorld Actors to do that.

What if their state change (Actors)
(The variable value update to the UI_Widget need to be differents at this point
(Destroyed damaged overheat plenty more),
wouldn’t it be more convenient to have them update the Ui_Widget (I might be very wrong here :slight_smile: )

Is it just more efficient to do it on the player?
Is their no other way around ?

Thank for the screenshot, It is quite clear !

it looks to me like your calling a interface event on the target item right? im guessing your calling that from the player. if thats the case why not just send a reference of the widget along with the interface call. that way you have a reference to the widget and you could change the image from there. or conversely you could call the interface event on the target item which inturn calls another interface event on the player and has an input for the image to display.

below is a little example text case for what i mention above. (back Top) basically i create a widget and make a variable which is a reference to the widget. then when i overlap the target item i call the interface event and pass along the widget reference via a input parameter. in the target item i just print out the widgets name to be sure it got the right one for testing purposes(lower left). you can also see that i have the input parameter set to widget to make things simpler (bottom right).

you are quite difficult to understand so its hard to tell what your trying to say.

Calling the interface is done by a Blueprint Actor in the GameWorld upon being tag by the player.

calling the interface event is what im doing in the character bp. the interface then executes on the actor in the world. it looked to me that you were using a trace to locate the actor in the world then calling the interface event with the hit actor as the target. so calling from the player character.

I am not able to get that Object Blueprint the reference it need to update the UI_Widget

this reference is what i was showing how to get. basically i created the reference to the widget in the player character then passed the reference via a parameter input through the interface and to the actor in the world. this could be just as easily done if you create the widget in another place but it looked like you created it in the character.

wouldn’t it be more convenient to have them update the Ui_Widget

this again is the kind of setup i was going for. in your case when the interface event executes you would set the image in the widget instead of the print string i used.

beyond that im not really sure what your saying so more clarification may be needed.

Yes, it was in fact better explained than my ability to read, I get what you mean now

Would it be normal that the Print Screen return
FirstPerson_UI_C_3
where the numeral values (3) can change for others values when I run the execution several times?

As you said the var number does not really impact anything as the number change but it remain consistent with the one set up in the firstPersonChar.

So the widget ref is correct.
I am just unable to use it the same way I use the one in the First PersonChar

FirstPersonChar Exemple

Actor Exemple

I tried to use it strait from the output of the event node
I also try to pass it trough a new var

Its all return the :
Object Widget Reference is not compatible with First person UI reference

At this point, I will continue to look for answer to that but my initial question have been answer correctly, Thanks!

whats being printed isnt all that important really (though it looks to be right). i would hook up the code your trying to make and see if it works that way.

all you need to do in this case is to cast the widget to the first person ui class. basically the set health percentage only exists in the first person ui class so you just need to use the cast to make sure the widget is of that class, or put another way identify the widgets class.

Working fine !

Very Appreciated !

Would like to give credit for a correct answer.
I do not seem to be able to edit a comment to an answer if it is not posted by me,
correct me if am wrong.

In the meantime, I will use this one to close the post