Sending a string from a actor blueprint to a widget

Hello,

So I have been trying to create a digital watch for my character to wear and I have set up a working day and night system with a timer that counts hours, minutes and seconds which is saved in a string which displays HH:MM:SS.

I need to try send this string to a widget that will attach to the players watch so you can see the time when looking at the wrist (or on clocks ect).

I have tried to reference the blueprint within the widget which turned out a “accessed none error”.

It wont be attached the the HUD like what most tutorials show since it will be a 3D widget attached to the characters wrist or to a clock mesh.

I have created a text box within the widget and then bind to it, but I am lost from there. What would be the best way to tackle this problem? It may be a simple issue but for the life of me I cant sort it.

Thank you.

Okay, I have been working with widgets for a couple of days and I can tell you how I did it. However I’m a newbie, so there might be simpler solutions.

First you need to store your Widget right after creating it in a variable (your Widget’s class name, not the Widget class) to be able to access its public functions later. Then, inside your Widget, you create a String variable and a public function, which sets the variable to the function’s input (which is also a String variable). Then you can call this function from the actor you saved the Widget as a variable in earlier, passing the desired String to the String variable inside your Widget - there you can access it.

Note: If the actor that spawns the widget is not the same actor which has the string you want to pass, it might get even more complicated.

Hope this helps!

Thank you for your reply.

I have just tried the above (or at least what I think is correct from above), I have the issue that when I try to reference the actual widget i get the “access none trying to read…” error.

I might be doing it wrong of course and I will keep tackling it.
If anyone could post a image demonstration of this method, I would be highly appreciative.

Thanks again.

Have you tried “connecting” those before adding them to viewport? Create widget → pass the reference to the widget → add widget to viewport.

Thank you, I got it working without the error now and I can get it to appear on the viewport.

My issue now is that in the the 3d widget blueprint, when it is placed my character blueprint, the string doesn’t appear and the text just disappears, since i need to attach this blueprint to my characters wrist, it’s important that it works. Do I need to make it refresh in the blueprint somehow?

Sorry for all the questions, you have been extremely helpful thus far!

Glad you got it working. As I said, I’m just recently started to learn UE myself - it just so happened that I have already been passing information from widgets to actors and vice versa, so I decided to share the way I do it. However, my widgets are GUI that is just sitting in the viewport and I have not been trying to attach them to objects yet, so I don’t think I can help you there. I hope you’ll figure it out! :slight_smile:

Ah, I understand.
You have been a great help! Thank you again!